A map of event to observers for the full time observers.
A map of event to observers for the one time observers.
Remove all observers to a given event. That is, no observers will be called when the event is emitted. Wether the observers were one time observers or full time observers is irrelevant, they are removed anyhow.
Event if all observers are removed, an observer may subscribe again to the event afterwards.
The event that the observers will be removed from.
The event emitter.
Add a particular observer to an event in the given map. If the event does not exists in the map, create it. If it does, add only the new observer. If the observer is already present for that event in the given map, do nothing.
Emit a particular event, calling all the observers that were registered to such event in the process, wether they were one time subscribers or full time subscribers.
After the emission, one time subscribers are removed as subscribers to the event, as they should not be called again.
The event to emit.
Remove an observer from a particular event of this event emitter. That is make the observer not to be called on future emits. If the observer is registered as a one time observer or as a full time observer is not relevant, it's removed anyhow. If an observer that is not registered is given, nothing happens, and no error is thrown.
Note that the observer is removed only to the specified event, and such it may still be registered for other events.
The event emitter.
Register a observer to a particular event of this event emitter, as a full time observer, that is, it will be called on the next emit of the event, and on all the following emits of such event.
If the observer is already present as a full time observer, it will remain as a full time observer. If it's a one time observer, it will be transformed to a full time observer.
The event emitter.
Register a observer to a particular event of this event emitter, as a one time observer, that is, it will be called on the next emit of the event, but not on the following emits of such event.
If the observer is already present as a one time observer, it will remain as a one time observer. If it's a full time observer, it will be transformed to a one time observer.
The event emitter.
Remove a particular observer from an event in the given map. If the observer does not exists in the event for the map, or the event is not present in the map, do nothing.
The EventEmitter class is a minimal observer pattern class definition. Instances of this class can be created directly, by
new EventEmitter()
or it can be used as a base class for custom definitions that require support for this pattern in order to allow subscription to custom events.The EventEmitter accepts as a type as a EventSignature, that is, a set of event names together with the expected parameters that the observer will be called with when the event occurs.