Travis build: 1099

This commit is contained in:
30secondsofcode
2018-01-09 12:19:51 +00:00
parent db5ca96a19
commit ba910cfe33
4 changed files with 90 additions and 5 deletions

View File

@ -8,7 +8,7 @@ For `on`, create an array for the event if it does not yet exist, then use `Arra
to the array.
For `off`, use `Array.findIndex()` to find the index of the handler in the event array and remove it using `Array.splice()`.
```js
```js
const createEventHub = () => ({
hub: Object.create(null),
emit(event, data) {
@ -25,7 +25,7 @@ const createEventHub = () => ({
});
```
```js
```js
const handler = data => console.log(data);
const hub = createEventHub();
let increment = 0;
@ -41,5 +41,5 @@ hub.emit('message', { hello: 'world' }); // logs the object and 'Message event f
hub.emit('increment'); // `increment` variable is now 1
// Unsubscribe: stop a specific handler from listening to the 'message' event
hub.off('message', handler);
hub.off('message', handler);
```