TypedEventEmitter
Extends
EventEmitter
Extended by
Type Parameters
Type Parameter |
---|
T extends Record <string , unknown []> |
Methods
emit()
Synchronously calls each of the listeners registered for the event named eventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
Type Parameters
Type Parameter |
---|
K extends string | symbol |
Parameters
Parameter | Type |
---|---|
eventName | K |
…args | T [Extract <K , string >] |
Returns
boolean
Overrides
EventEmitter.emit
Since
v0.1.26
Defined in
off()
Alias for emitter.removeListener()
.
Type Parameters
Type Parameter |
---|
K extends string | symbol |
Parameters
Parameter | Type |
---|---|
eventName | K |
listener | (…args : T [Extract <K , string >]) => void |
Returns
this
Overrides
EventEmitter.off
Since
v10.0.0
Defined in
on()
Adds the listener
function to the end of the listeners array for the event
named eventName
. No checks are made to see if the listener
has already
been added. Multiple calls passing the same combination of eventName
and
listener
will result in the listener
being added, and called, multiple times.
Returns a reference to the EventEmitter
, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependListener()
method can be used as an alternative to add the
event listener to the beginning of the listeners array.
Type Parameters
Type Parameter |
---|
K extends string | symbol |
Parameters
Parameter | Type | Description |
---|---|---|
eventName | K | The name of the event. |
listener | (…args : T [Extract <K , string >]) => void | The callback function |
Returns
this
Overrides
EventEmitter.on
Since
v0.1.101
Defined in
once()
Adds a one-time listener
function for the event named eventName
. The
next time eventName
is triggered, this listener is removed and then invoked.
Returns a reference to the EventEmitter
, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener()
method can be used as an alternative to add the
event listener to the beginning of the listeners array.
Type Parameters
Type Parameter |
---|
K extends string | symbol |
Parameters
Parameter | Type | Description |
---|---|---|
eventName | K | The name of the event. |
listener | (…args : T [Extract <K , string >]) => void | The callback function |
Returns
this
Overrides
EventEmitter.once
Since
v0.3.0