-
Notifications
You must be signed in to change notification settings - Fork 0
EventEmitter.emitSeries
Executes all listeners for specified events serially. That is only one listener is executed at a time. If that listener returns a promise, the emitter wait the promise to be resolved before continue with the next listener.
emitter.emitSeries(event, args...);| Argument | Type | Required | Description |
|---|---|---|---|
| event | string | ✓ | The name of the event. |
| args | any | Arguments given to each listener. |
A promise to a Map (from hash-me library) with keys the listener functions and the values the return value of the corresponding listener function. If a listener function returns a promise, the value in the map is the value to which promise has been resolved.
If any listener or the library itself throws an exception (including unintentional one) the return value is rejected promise with the exception for the reason.
If any listener returns a rejected promise, the promise returned is also rejected with the same reason.
The method returns reject promise with reason ReferenceError if current graph is not dependency graph, e.g. it has cycles. To distinguish between ReferenceError thrown by bug and intentionally, intentional ReferenceError will have code equal to CIRCULAR_REFERENCE string.
The function does not throws an exception, instead it returns rejected promise.
Due to nature of execution, this function guarantees that if a listener throws an exception or return a rejected promise, no other listeners would be called.