From 217bf29360172c4af56c409291c22ce38fa7377a Mon Sep 17 00:00:00 2001 From: atomiks Date: Sat, 6 Jan 2018 01:26:07 +1100 Subject: [PATCH] Update createEventHub.md --- snippets/createEventHub.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/createEventHub.md b/snippets/createEventHub.md index 65690fa92..66c718bc7 100644 --- a/snippets/createEventHub.md +++ b/snippets/createEventHub.md @@ -21,7 +21,7 @@ const createEventHub = () => ({ this.hub[event].push(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); } });