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.

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');