addListener()
typescript
instance.addListener("foo", () => {
/* [...] */
});
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
event | string | symbol | The event name. Expects an ESMitterEventName. | |
fn | unknown | The function that will be called then the event is emitted. | |
context | unknown | undefined | The context to invoke the listener with. |
once | boolean | false | Specify if the listener is a one-time listener. |
on()
The on()
method is almost an alias of addListener()
, the only exception being the missing once
parameter. For this, use once()
instead.