SDK
SDK Javascript v7.x
2

prependListener #

Adds a listener function to the beginning of the listeners array for an event.

Arguments #

Copied to clipboard!
prependListener(eventName, callback);

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

Return #

The KuzzleEventEmitter instance.

Usage #

Copied to clipboard!
const eventEmitter = new KuzzleEventEmitter();
eventEmitter.addListener('myEvent', () => console.log('listener1'));
eventEmitter.prependListener('myEvent', () => console.log('listener2'));
// Prints:
//   listener2
//   listener1
eventEmitter.emit('myEvent');