The expected type (function signature) of the event listeners.
Create an OEvent object.
The type of the event.
Type of execution. See class descriptions for more detail.
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.
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.
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.
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.
Returns the number of registered event listeners.
Register a listener to be triggered when a new listener is registered for this event.
Register a listener to be triggered when a listener is unregistered from this event.
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.