From 8700977e3897683656283630d8c057e29eafed41 Mon Sep 17 00:00:00 2001 From: atomiks Date: Sat, 6 Jan 2018 00:09:51 +1100 Subject: [PATCH] Update createEventHub.md --- snippets/createEventHub.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/createEventHub.md b/snippets/createEventHub.md index 9804e9e4a..c1cd73097 100644 --- a/snippets/createEventHub.md +++ b/snippets/createEventHub.md @@ -3,12 +3,12 @@ Creates a pubsub event hub with `emit`, `on`, and `off` methods. For `emit`, resolve the array of handlers based on the `event` argument and then run -each one by passing in the data as an argument. +each one with `Array.forEach()` by passing in the data as an argument. -For `on`, create an array for the event if it does not yet exist, then push the handler -into the array. +For `on`, create an array for the event if it does not yet exist, then use `Array.push()` to add the handler +to the array. -For `off`, find the index of the handler in the event array and remove it. +For `off`, use `Array.findIndex()` to find the index of the handler in the event array and remove it. ```js const createEventHub = () => ({