Class: EventEmitter
Constructors
constructor
• new EventEmitter()
Properties
listeners
• Private
Readonly
listeners: Map
<string
, Set
<EventListener
<any
>>>
Defined in
allListeners
• Private
Readonly
allListeners: Set
<AllEventsListener
<any
>>
Defined in
Methods
on
▸ on(event
, listener
): void
Add an event handler for a specific event
Parameters
Name | Type | Description |
---|---|---|
event | "*" | The event name |
listener | AllEventsListener <any > | A event handler function |
Returns
void
Defined in
▸ on(event
, listener
): void
Parameters
Name | Type |
---|---|
event | string |
listener | EventListener <any > |
Returns
void
Defined in
off
▸ off(event
, listener?
): void
Remove an event handler of a specific event name or remove all event handlers for a specific event.
Parameters
Name | Type | Description |
---|---|---|
event | "*" | The event name where a specific or all handlers should be removed |
listener? | AllEventsListener <any > | An optional event handler function. If specified only this specific handler will be removed and otherwise all handlers are removed. |
Returns
void
Defined in
▸ off(event
, listener?
): void
Parameters
Name | Type |
---|---|
event | string |
listener? | EventListener <any > |
Returns
void
Defined in
emit
▸ emit<T
>(event
, data
): void
Use this function to emit an event. All handlers that are listening for this event will be triggered with the data parameter.
Type parameters
Name | Type |
---|---|
T | any |
Parameters
Name | Type | Description |
---|---|---|
event | string | The event name that should be triggered |
data | T | Arbitrary data that will be passed to the event handler callback functions |
Returns
void