Skip to content

removeListener()

Removes listeners for a given event. You can specify a function, context, and/or whether to remove only one-time listeners.

Example

typescript
instance.removeListener("foo", fn);
instance.removeListener("foo", fn, context);
instance.removeListener("foo", fn, context, true); // Remove one-time listeners
instance.removeListener("foo"); // Remove all listeners for "foo"

Parameters

ParameterTypeDefaultDescription
eventstring | symbolThe event name. Expects an ESMitterEventName.
fnunknownOnly remove listeners that match this function.
contextunknownOnly remove listeners that have this context.
oncebooleanOnly remove one-time listeners.

Returns

TypeDescription
ESMitterThe ESMitter instance, allowing for method chaining.

Notes

  • If no function is provided, all listeners for the event are removed.
  • This method is aliased by off().