Skip to content

emit()

Calls each of the listeners registered for a given event, passing any arguments to the listeners.

Example

typescript
instance.emit("foo", arg1, arg2);

Parameters

ParameterTypeDescription
eventstring | symbolThe event name. Expects an ESMitterEventName.
...argsunknown[]Arguments to pass to the listeners.

Returns

TypeDescription
booleantrue if the event had listeners, else false.

Notes

  • If a listener is registered as a one-time listener (using once()), it will be removed after being called.
  • Listeners are called with the provided arguments and their specified context.