SDK
SDK Javascript v7.x
2

addOnceListener #

Adds a one-time listener function to an event.
The next time the event is triggered, this listener is removed and then invoked.
Whenever an event is triggered, listener functions are called in the order they were registered.

Arguments #

addOnceListener(eventName, callback);

ArgumentTypeDescription
eventName
string
The name of the event
callback
function
Function to call when the event is triggered

Return #

The KuzzleEventEmitter instance.

Usage #

const eventEmitter = new KuzzleEventEmitter();
eventEmitter.addOnceListener(
  'myEvent',
  () => console.log('Caught event "myEvent"!'));
// Prints: Caught event "myEvent"!
eventEmitter.emit('myEvent');
// Prints nothing: the event has since been removed
eventEmitter.emit('myEvent');