EventEmitterT
EventEmitter generic class
These objects expose an on() function that allows one or more functions to be attached to named events emitted by the object. When the EventEmitter object emits an event, all of the functions attached to that specific event are called synchronously. Any values returned by the called listeners are ignored and discarded.
Extends
Section titled “Extends”EventEmitterTI
<Events
,this
>
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”Events
Section titled “Events”Events
Events emitted by EventEmitter
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new EventEmitterT<
Events
>():EventEmitterT
<Events
>
Returns
Section titled “Returns”EventEmitterT
<Events
>
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> })<Events>.constructor
Methods
Section titled “Methods”addListener()
Section titled “addListener()”addListener<
E
>(event
,listener
):this
Adds the listener function to the end of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”Events
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).addListener
emit()
Section titled “emit()”emit<
E
>(event
, …args
):boolean
Synchronously calls each of the listeners registered for the event
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
…Args
<Events
[E
]>
Arguments passed to the listeners
Returns
Section titled “Returns”boolean
True if the event had listeners, False otherwise
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).emit
eventNames()
Section titled “eventNames()”eventNames(): (
string
|symbol
| keyofEvents
)[]
List of emitter’s events
Returns
Section titled “Returns”(string
| symbol
| keyof Events
)[]
List of emitter’s events
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).eventNames
getMaxListeners()
Section titled “getMaxListeners()”getMaxListeners():
number
Maximum number of listeners per event
Returns
Section titled “Returns”number
Maximum number of listeners per event
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).getMaxListeners
listenerCount()
Section titled “listenerCount()”listenerCount<
E
>(event
):number
The number of listeners listening to the event
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”number
Number of listeners
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).listenerCount
listeners()
Section titled “listeners()”listeners<
E
>(event
):Function
[]
Copy of the array of listeners for the event
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”Function
[]
Copy of the listeners array
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).listeners
off<
E
>(event
,listener
):this
Removes the listener from the listener array for the event
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”Events
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).off
on<
E
>(event
,listener
):this
Adds the listener function to the event
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”Events
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).on
once()
Section titled “once()”once<
E
>(event
,listener
):this
Adds a one-time listener function for the event
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”Events
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).once
prependListener()
Section titled “prependListener()”prependListener<
E
>(event
,listener
):this
Adds the listener function to the beginning of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”Events
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).prependListener
prependOnceListener()
Section titled “prependOnceListener()”prependOnceListener<
E
>(event
,listener
):this
Adds a one-time listener function to the beginning of the listeners array
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”Events
[E
]
The callback function
Returns
Section titled “Returns”this
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).prependOnceListener
rawListeners()
Section titled “rawListeners()”rawListeners<
E
>(event
):Function
[]
Copy of the array of listeners for the event including wrappers
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
Returns
Section titled “Returns”Function
[]
Copy of the listeners array
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).rawListeners
removeAllListeners()
Section titled “removeAllListeners()”removeAllListeners<
E
>(event?
):this
Removes all listeners, or those of the specified event
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”event?
Section titled “event?”E
The name of the event
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).removeAllListeners
removeListener()
Section titled “removeListener()”removeListener<
E
>(event
,listener
):this
Removes the specified listener from the listener array
Type Parameters
Section titled “Type Parameters”E
extends string
| number
| symbol
Parameters
Section titled “Parameters”E
The name of the event
listener
Section titled “listener”Events
[E
]
The callback function
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).removeListener
setMaxListeners()
Section titled “setMaxListeners()”setMaxListeners(
n
):this
Sets maximum number of listeners per event
Parameters
Section titled “Parameters”number
Maximum number of listeners
Returns
Section titled “Returns”this
This EventEmitter
Inherited from
Section titled “Inherited from”(EventEmitter as { new<Events>(): EventEmitterTI<Events> }).setMaxListeners