From 93a119bf4b635f5d0f137ef34bcd66acf7c3b13c Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Wed, 17 May 2017 10:54:09 -0400 Subject: [PATCH] fix(core): fix issues when clearing observables --- src/@ionic-native/core/plugin.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/@ionic-native/core/plugin.ts b/src/@ionic-native/core/plugin.ts index 362c72255..a00695a4b 100644 --- a/src/@ionic-native/core/plugin.ts +++ b/src/@ionic-native/core/plugin.ts @@ -177,11 +177,11 @@ function wrapObservable(pluginObj: any, methodName: string, args: any[], opts: a if (opts.clearWithArgs) { return callCordovaPlugin(pluginObj, opts.clearFunction, args, opts, observer.next.bind(observer), observer.error.bind(observer)); } - return get(window, pluginObj.constructor.getPluginRef())[opts.clearFunction].call(pluginObj, pluginResult); + return callCordovaPlugin(pluginObj, opts.clearFunction, []); } } catch (e) { console.warn('Unable to clear the previous observable watch for', pluginObj.constructor.getPluginName(), methodName); - console.error(e); + console.warn(e); } }; }); @@ -276,12 +276,12 @@ export function wrapInstance(pluginObj: any, methodName: string, opts: any = {}) return () => { try { if (opts.clearWithArgs) { - return pluginObj._objectInstance[opts.clearFunction].apply(pluginObj._objectInstance, args); + return callInstance(pluginObj, opts.clearFunction, args, opts, observer.next.bind(observer), observer.error.bind(observer)); } - return pluginObj._objectInstance[opts.clearFunction].call(pluginObj, pluginResult); + return callInstance(pluginObj, opts.clearFunction, []); } catch (e) { console.warn('Unable to clear the previous observable watch for', pluginObj.constructor.getPluginName(), methodName); - console.error(e); + console.warn(e); } }; });