addListener #
Adds a listener function to the end of the listeners array for an event.
Whenever an event is triggered, listener functions are called in the order they were registered.
Arguments #
addListener (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('Caught event "myEvent"!'));
// Prints: Caught event "myEvent"!
eventEmitter.emit('myEvent');
Edit this page on Github (opens new window)