From f94cd92322e651dd487cb1e84f6074cc8633e528 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 11 Dec 2017 08:40:53 +0100 Subject: [PATCH] MOBILE-2302 core: Fix unsubscribe in CoreEventsProvider --- src/providers/events.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/providers/events.ts b/src/providers/events.ts index 60d8cf9f6..ee551eeb5 100644 --- a/src/providers/events.ts +++ b/src/providers/events.ts @@ -48,7 +48,7 @@ export class CoreEventsProvider { public static APP_LAUNCHED_URL = 'app_launched_url'; // App opened with a certain URL (custom URL scheme). logger; - observables = {}; + observables: {[s: string] : Subject} = {}; uniqueEvents = {}; constructor(logger: CoreLoggerProvider) { @@ -65,7 +65,7 @@ export class CoreEventsProvider { * @param {Function} callBack Function to call when the event is triggered. * @return {CoreEventObserver} Observer to stop listening. */ - on(eventName: string, callBack: Function) : CoreEventObserver { + on(eventName: string, callBack: (value: any) => void) : CoreEventObserver { // If it's a unique event and has been triggered already, call the callBack. // We don't need to create an observer because the event won't be triggered again. if (this.uniqueEvents[eventName]) { @@ -83,13 +83,13 @@ export class CoreEventsProvider { this.observables[eventName] = new Subject(); } - this.observables[eventName].subscribe(callBack); + let subscription = this.observables[eventName].subscribe(callBack); // Create and return a CoreEventObserver. return { off: () => { this.logger.debug(`Stop listening to event '${eventName}'`); - this.observables[eventName].unsubscribe(callBack); + subscription.unsubscribe(); } }; }