Methods
# addListener(eventName, eventHandler)
Add an event listener.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | The name of the event to capture, or true to capture all events |
eventHandler |
function | The function to invoke when the eventHandler is invoked. The arguments to the function are specified by the code emitting the event, however a final argument, eventName, is appended to event handlers invoked via catch-alls. |
# emit(eventName)
Emit an event.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | The event to emit |
... |
Any other arguments passed will be passed exactly to the listener. |
# once(eventName, eventHandler)
Attach a callback (eventHandler) to a named event. It will be called once when this event emitter emits that event and then removed.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | Name of event |
eventHandler |
function | Function to call |
# removeListener(eventName, eventHandler)
Remove a listener (eventHandler
) attached to a named event. It must
be the same eventHandler
instance that was originally attached.
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | Name of event |
eventHandler |
function | Function to call |