Update formatting

This commit is contained in:
Isabelle Viktoria Maciohsek
2022-01-30 18:27:55 +02:00
parent c08892459a
commit 9cb319d726
6 changed files with 8 additions and 8 deletions

View File

@ -7,7 +7,7 @@ lastUpdated: 2020-09-15T16:28:04+03:00
Creates a pub/sub ([publishsubscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern)) event hub with `emit`, `on`, and `off` methods.
- Use `Object.create(null)` to create an empty `hub` object that does not inherit properties from `Object.prototype`.
- Use `Object.create()` with an argument of `null` to create an empty `hub` object that does not inherit properties from `Object.prototype`.
- For `emit`, resolve the array of handlers based on the `event` argument and then run each one with `Array.prototype.forEach()` by passing in the data as an argument.
- For `on`, create an array for the event if it does not yet exist, then use `Array.prototype.push()` to add the handler
- to the array.