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 #

Copied to clipboard!
addOnceListener(eventName, callback);

Argument Type Description
eventName
string
The name of the event
callback
function
Function to call when the event is triggered

Return #

The KuzzleEventEmitter instance.

Usage #

Copied to clipboard!
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');