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.

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