mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user