From d3e6f3ba41e334b3fc0894104fc31af7c24959e0 Mon Sep 17 00:00:00 2001 From: Ramon Henrique Ornelas Date: Sat, 8 Oct 2016 16:07:01 -0300 Subject: [PATCH] refactor(plugin): improvement pull #654 (#661) --- src/plugins/plugin.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/plugin.ts b/src/plugins/plugin.ts index fb02c5638..ec11b3cd1 100644 --- a/src/plugins/plugin.ts +++ b/src/plugins/plugin.ts @@ -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] @@ -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; }