Core 2.x

removeListener

Removes a listener function from an event.

Arguments

Copied to clipboard!
removeListener(eventName, callback);

Argument Type Description
eventName
string
The name of the event
callback
function
Callback to remove

Return

The KuzzleEventEmitter instance.

Usage

Copied to clipboard!
const eventEmitter = new KuzzleEventEmitter();
const listener = () => console.log('disconnected');
eventEmitter
  .addListener('disconnected', () => console.log('disconnected'))
  .addListener('disconnected', listener);
eventEmitter.removeListener('disconnected', listener);
if (eventEmitter.listeners('disconnected').length === 1) {
  console.log('Successfully removed the listener');
}