Helper functions for writing event driven systems.
Subscribe to and publish events.
Subscribe an event handler
Name | Type | Description |
---|---|---|
eventName | string | The name of the event |
handler | Function | The function to be executed when the event is emitted |
Function
Returns the handler for easy unsubscription
Unsubscribe an event handler
Name | Type | Description |
---|---|---|
eventName | string | The name of the event |
handler | Function | The handler to be removed |
Void
Publish an event
Name | Type | Description |
---|---|---|
eventName | string | The name of the event |
event | Object | The parameter to pass to the event handlers |
Void
A list that can have a handler(s) invoked any time the list is modified.
The collection constructor with an optional initial value parameter
Name | Type | Description |
---|---|---|
init | Array | An array to initialize the collection with |
Collection<T>
Returns the new collection
Subscribe an event handler to be called whenever the collection is modified
Name | Type | Description |
---|---|---|
handler | Function | The collection changed handler |
Function
Returns a function that when executed will remove the collection changed handler
Add a value to the collection
Name | Type | Description |
---|---|---|
value | T | The value to be added to the collection |
Void
Add a range of values to the collection
Name | Type | Description |
---|---|---|
values | Array | The range of values to be added to the collection |
Void
Remove the value from the collection
Name | Type | Description |
---|---|---|
value | T | The value to be removed from the collection |
Void
Removes all items within the collection
Void
Returns a copy of the list in the form of an array
Array<T>
A copy of the collection