Update createEventHub.md

This commit is contained in:
atomiks
2018-01-06 01:26:07 +11:00
committed by GitHub
parent 4b6b5743c5
commit 217bf29360

View File

@ -21,7 +21,7 @@ const createEventHub = () => ({
this.hub[event].push(handler); this.hub[event].push(handler);
}, },
off(event, handler) { off(event, handler) {
const i = this.hub[event].findIndex(h => h === handler); const i = (this.hub[event] || []).findIndex(h => h === handler);
if (i > -1) this.hub[event].splice(i, 1); if (i > -1) this.hub[event].splice(i, 1);
} }
}); });