Update createEventHub.md

This commit is contained in:
atomiks
2018-01-09 08:42:54 +11:00
committed by GitHub
parent 6885ab113c
commit d0cfcd095b

View File

@ -30,10 +30,10 @@ const createEventHub = () => ({
``` ```
```js ```js
const fn = data => console.log(data); const fn = data => console.log(data.hello);
const hub = createEventHub(); const hub = createEventHub();
hub.on('message', fn); // subscribe a handler to listen for 'message' events hub.on('message', fn); // subscribe the handler to listen for 'message' events
hub.emit('message', 'hello!'); // console logs 'hello!' hub.emit('message', { hello: 'world' }); // logs 'world'
hub.off('message', fn); // unsubscribe our handler from 'message' hub.off('message', fn); // unsubscribe the handler from 'message' events
``` ```