Methods
addListener(eventNameopt, callbackopt, onceopt)
Adds a listener callback for a given event name.
If you pass `EventHandler.ALL_EVENTS` then the callback will receive all events, regardless of name.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
eventName |
Object | Symbol |
<optional> |
a string or Symbol indicating the event to watch | |
callback |
eventCallback |
<optional> |
often includes more parameters that are specific to the event | |
once |
boolean |
<optional> |
false | If true then the listener is removed after receiving one event |
- Source:
cleanup() → {EventHandler}
Removes all references to listener callbacks.
This should be called by extending classes.
- Source:
Returns:
returns `this` for chaining
- Type
- EventHandler
removeListener(eventName, callback)
Removes reference to a specific listener.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | Symbol | EventHandler.ALL_EVENTS | |
callback |
function | the function originally passed into EventhHandler.addListener. |
- Source:
trigger(eventName, …params)
Send an event to listeners
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string | an identifier for the event like 'changed:fieldName' or 'deleted' | |
params |
* |
<repeatable> |
the parameters handed to the listeners |
- Source:
Type Definitions
eventCallback(eventName, …params)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string | an identifier for the event like 'changed:fieldName' or 'deleted' | |
params |
* |
<repeatable> |
the parameters handed to the listeners |
- Source: