Invokes all event listeners.
If a listener throws an error - or a listener returns a promise that rejects - the following will happen:
The listeners will be executed in parallel or sequentially based on the executeSequentially flag set in the constructor.
Rest
...listenerArguments: Parameters<T>Arguments are passed to the invoked listeners.
Invokes all event listeners and returns the results of all listeners.
Even if the listeners have a return value of void / Promise
It behaves like Promise.all() over all event listeners.
Rest
...listenerArguments: Parameters<T>Arguments are passed to the invoked listeners.
Invoke all listeners and return the result of the first resolved promise.
All event listeners will be executed in parallel - even if executeSequentially is set to true. It just does not make sense to have a race between listeners and then invoke them sequentially.
It behaves like Promise.race() over all event listeners.
Rest
...listenerArguments: Parameters<T>Arguments are passed to the invoked listeners.
Registers a listener to be executed when the event is emitted.
a function that disconnects the listener. If executeSequentially is true: No further calls to the event listener will be made after this call. If executeSequentially is false: Further calls might happen when the disconnect happens in another event listener.
Event handling class.
This class manages event listeners and their invocation. Listeners are registered with the listen method - or better by using the () operator of this class - and can be invoked with one of the emit* methods:
Executing handlers sequentially vs parallel:
emit & emitAll offer the possibility to execute the listeners handlers in parallel or sequentially.This is configurable through the 'executeSequentially' optional parameter in the constructor. 'executeSequentially' defaults to true.
Usage:
OEvent is chosen as class name over Event, because the second option is reserved.