prependListener #
Adds a listener function to the beginning of the listeners array for an event.
Arguments #
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 #
const eventEmitter = new KuzzleEventEmitter();
eventEmitter.addListener('myEvent', () => console.log('listener1'));
eventEmitter.prependListener('myEvent', () => console.log('listener2'));
// Prints:
// listener2
// listener1
eventEmitter.emit('myEvent');
Edit this page on Github(opens new window)