Subscribe to this event using the given listener. The listener will be invoked any time the event is emitted. The returned handle can be used to unsubscribe.
listener to subscribe
handle to the subscription, can be used to unsubscribe
Create a subscribable that will apply the specified filter to any listeners added.
function used to filter events
Rest
...args: Argsfiltered Subscription
Create an iterator that supports async iteration of events emitted.
Optional
options: EventIteratorOptionsoptions for this iterator
iterable/iterator
Subscribe to this event using the given listener. The listener will be invoked any time the event is emitted. The returned handle can be used to unsubscribe.
listener to subscribe
handle to the subscription, can be used to unsubscribe
Unsubscribe a listener from this handler. The specified listener will no longer be invoked when the event is emitted.
listener to unsubscribe
Create a Subscribable that changes the this argument used for listeners.
what should be treated as this for event listeners
modified Subscribable
Generated using TypeDoc
Function that can be used to subscribe, filter and iterate over events. Subscribables are commonly fetched from an Event, adapted from another event emitters using createEventAdapter or manually created via createSubscribable.
Subscribing and unsubscribing
Subscribables are functions that allow them to be called directly to subscribe to the event:
It is also possible to subscribe/unsubscribe a listener using methods on the subscribable:
Filtering
Subscribables may be filtered to create an instance that only emits certain events:
Listening to something once
Listening for a single event may be done via once which returns a promise:
Async iteration of events
Subscribables can also be used with an async iterator to allow for event loops:
With default values:
Sometimes events are emitted faster than they can be consumed, limiting and controlling overflow of events can be done via iterator.
As an example this will limit to 10 queued events and then start dropping the earliest ones:
The behavior to use when the queue is full can be controlled by setting the overflow behavior to either DropNewest or DropOldest.