silence error for emit
This commit is contained in:
@ -14,7 +14,7 @@ For `off`, use `Array.findIndex()` to find the index of the handler in the event
|
|||||||
const createEventHub = () => ({
|
const createEventHub = () => ({
|
||||||
hub: {},
|
hub: {},
|
||||||
emit(event, data) {
|
emit(event, data) {
|
||||||
this.hub[event].forEach(handler => handler(data));
|
(this.hub[event] || []).forEach(handler => handler(data));
|
||||||
},
|
},
|
||||||
on(event, handler) {
|
on(event, handler) {
|
||||||
if (!this.hub[event]) this.hub[event] = [];
|
if (!this.hub[event]) this.hub[event] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user