Dispatching Event
To dispatch event:
aggregator.get('some event').dispatch(args, noListenersCallback, enqueuedCallback);
In which:
args
is an object that provides arguments for event listeners.noListenerCallback
is a callback function that will be invoked if there is no listeners listening to the specified event. This function accepts no parameters.enqueuedCallback
is in constrast tonoListenerCallback
, will be invoked when there is at least one listener and the event is about to be dispatched. This function accepts no parameters.
Below is an example:
aggregator.get('Price Changed').dispatch(12.00, () => {
console.log('No listeners');
}, () => {
console.log('Event enqueued');
})
Last updated