From 96de5d9c31323910086773a726e75e4fada4e601 Mon Sep 17 00:00:00 2001 From: Ibby Date: Sat, 11 Mar 2017 11:13:40 -0500 Subject: [PATCH] chore(): add options to InstanceCheck --- src/@ionic-native/core/decorators.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/@ionic-native/core/decorators.ts b/src/@ionic-native/core/decorators.ts index f9eac67bb..a793d9b3e 100644 --- a/src/@ionic-native/core/decorators.ts +++ b/src/@ionic-native/core/decorators.ts @@ -115,14 +115,22 @@ export interface CordovaFiniteObservableOptions extends CordovaOptions { /** * @private */ -export function InstanceCheck() { - return (pluginObj: Object, methodName: string, descriptor: TypedPropertyDescriptor) => { +export function InstanceCheck(opts: CordovaCheckOptions = {}) { + return (pluginObj: Object, methodName: string, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor => { return { - value: function(...args: any[]) { + value: function(...args: any[]): any { if (instanceAvailability(pluginObj, methodName)) { descriptor.value.apply(this, args); } else { + + if (opts.promise) { + return getPromise(() => {}); + } else if (opts.observable) { + return new Observable(() => {}); + } + return null; + } } }; @@ -144,7 +152,7 @@ export function CordovaCheck(opts: CordovaCheckOptions = {}) { if (opts.promise) { return getPromise(() => {}); } else if (opts.observable) { - return new Observable(observer => observer.complete()); + return new Observable(() => {}); } return null;