Methods
emit(name, …argsopt)
Calls all previously added listeners for the given event name.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | ||
args |
* |
<optional> <repeatable> |
hasListeners(nameopt) → {boolean}
Checks whether there are any listeners for the specified event.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string |
<optional> |
The name of the event. If omitted, checks whether there are any listeners for any event. |
Returns:
- Type
- boolean
listeners(name) → {Array.<function()>}
Returns a copy of the array of listeners for the specified event.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Returns:
- Type
- Array.<function()>
off(name, listener)
Removes a listener for the specified event name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
listener |
function |
on(name, listener)
Adds a listener for the specified event name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
listener |
function |
once(name) → {Promise}
Adds a one time listener and returns a promise that
is resolved the next time the specified event is emitted.
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Returns:
- Type
- Promise