SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

removeAllListeners #

Removes all listener functions from an event.
If no eventName is specified, removes all listener functions from all events.

Arguments #

removeAllListeners([eventName]);

ArgumentTypeDescription
eventName
string
Optional name of the event

Return #

The KuzzleEventEmitter instance.

Usage #

const eventEmitter = new KuzzleEventEmitter();
eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent" (1)'));
eventEmitter.addListener('myEvent', () => console.log('Caught event "myEvent" (2)'));
// Prints:
//   Caught event "myEvent" (1)
//   Caught event "myEvent" (2)
eventEmitter.emit('myEvent');
eventEmitter.removeAllListeners('myEvent');
// Prints nothing: all events have been removed
eventEmitter.emit('myEvent');
if (eventEmitter.listeners('myEvent').length === 0) {
  console.log('Successfully removed all listeners');
}