Skip to content

off()

Removes listeners for a given event. This method is an alias of removeListener().

Example

typescript
instance.off("foo", fn);
instance.off("foo", fn, context);
instance.off("foo", fn, context, true); // Remove one-time listeners
instance.off("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 functionally identical to removeListener().