- Source:
Methods
emit(event, …argsopt) → {array}
Emit an event synchronously. This emit will execute all matching handlers and return an array of their return values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | The name of the event to emit (use full-stop '.' as a namespace delimiter). | |
args |
* |
<optional> <repeatable> |
Any number of arguments to pass to all event handlers. |
- Source:
Returns:
An array of all the values returned by event handlers in the order they were executed.
- Type
- array
emitAsync(event, …argsopt) → {Promise.<array>}
Emit an event asynchronously. This emit will execute all matching handlers concurrently (in parallel) and return an
array of their return values.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | The name of the event to emit (use full-stop '.' as a namespace delimiter). | |
args |
* |
<optional> <repeatable> |
Any number of arguments to pass to all event handlers. |
- Source:
Returns:
A Promise that will resolve to an array of all the values returned by the event handlers in the order they were matched.
- Type
- Promise.<array>
emitWaterfall(event, …argsopt)
Emit an event synchronously and in order where the output of each handler in the chain becomes the input to the next.
The exception to this rule is that returning undefined from a handler will be interpreted as "leave the data unchanged".
If the intention of a handler is to continue execution, but replace the data of previous steps with undefined, return "event.continueWithUndefined" instead
of simply returning undefined. If the intention is to halt execution of subsequent steps and return undefined overall, return "event.returnUndefined"
where "event" is the first parameter passed to each handler.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | The name of the event to emit (use full-stop '.' as a namespace delimiter). | |
args |
* |
<optional> <repeatable> |
Any number of arguments to pass to the first event handler. |
- Source:
Returns:
The return value of the last event handler that executed and returned a value.
emitWaterfallAsync(event, …argsopt)
An asynchronous version of EventEmitter#emitWaterfall
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | The name of the event to emit (use full-stop '.' as a namespace delimiter). | |
args |
* |
<optional> <repeatable> |
Any number of arguments to pass to the first event handler. |
- Source:
- See:
Returns:
The return value of the last event handler that executed and returned a value.
on(event, handler)
Register an event handler. The event handler will be called when any event matching the event string is emitted. The order of execution and parameters
passed to the handler can change based on which emit was used. EventEmitter#emit EventEmitter#emitWaterfall.
Parameters:
Name | Type | Description |
---|---|---|
event |
string | The name (or matching string) of the event you want the handler to be registered against. |
handler |
function | The event handler to register. |
- Source: