diff --git a/angular/src/providers/events.ts b/angular/src/providers/events.ts index 165755bba5..4a63faaf6c 100644 --- a/angular/src/providers/events.ts +++ b/angular/src/providers/events.ts @@ -14,7 +14,7 @@ export class Events { subscribe(topic: string, ...handlers: Function[]) { let topics = this.c.get(topic); if (!topics) { - topics = []; + this.c.set(topic, topics = []); } topics.push(...handlers); } @@ -62,7 +62,14 @@ export class Events { if (!topics) { return null; } - return topics.map((handler => handler(...args))); + return topics.map(handler => { + try { + return handler(...args); + } catch (e) { + console.error(e); + return null; + } + }); } }