Skip to content

Commit

Permalink
refactor(plugin): improvement pull #654 (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonornela authored and ihadeed committed Oct 8, 2016
1 parent 2c6cc37 commit d3e6f3b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export const cordovaWarn = function(pluginName: string, method: string) {
}
};
function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Function): any {
// ignore resolve and reject in case sync
if (opts.sync) {
return args;
}

// If the plugin method expects myMethod(success, err, options)
if (opts.callbackOrder === 'reverse') {
// Get those arguments in the order [resolve, reject, ...restOfArgs]
Expand Down Expand Up @@ -77,10 +82,8 @@ function setIndex(args: any[], opts: any = {}, resolve?: Function, reject?: Func
} else {
// Otherwise, let's tack them on to the end of the argument list
// which is 90% of cases
if (!opts.sync) {
args.push(resolve);
args.push(reject);
}
args.push(resolve);
args.push(reject);
}
return args;
}
Expand Down

0 comments on commit d3e6f3b

Please sign in to comment.