Constructor
# new Events(propsopt)
Constructs an event emitter
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
props |
ConstructorParams |
<optional> |
parameters to configure the emitter |
Classes
Methods
# emit(event, …params) → {Array.<any>}
Emits an event synchronously
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | the event to emit | |
params |
params |
<repeatable> |
the parameters to call the event with |
- an array of the parameters the event was called with
Array.<any>
# async emitAsync(event, …params) → {Array.<any>}
Emits events asynchronously, in order, sequentially
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | the event to emit | |
params |
params |
<repeatable> |
the parameters to call the event with |
- an array of the parameters the event was called with
Array.<any>
# async emitAtOnce(event, …params) → {Array.<any>}
Emits events asynchronously, in parallel
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event |
string | the event to emit | |
params |
params |
<repeatable> |
the parameters to call the event with |
- an array of the parameters the event was called with
Array.<any>
# off(names, handleropt)
Removes a listener from a pattern
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
names |
string | Array.<string> | the pattern(s) of the handler to remove | |
handler |
function |
<optional> |
the handler to remove, or all handlers |
# on(names, handler)
Adds an event listener with wildcards etc
Parameters:
Name | Type | Description |
---|---|---|
names |
string | Array.<string> | the event patterns to handle |
handler |
function | the handler for the pattern |
# once(name, handler)
Add an event listener that will fire only once, if multiple
patterns are provided it will only fire on the first one
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Array.<string> | the event pattern to listen for |
handler |
function | the function to invoke |