Adapt an event emitted by a Node EventEmitter or by a DOM event target.
Adapters are useful when wanting to bridge events from a third-party library
or from the DOM.
This adapter will register every listener with the event emitter, and let
you use the Subscribable API to subscribe, unsubscribe, filter and
iterate over events.
Three different types of event emitters are supported:
Emitters with on and off methods, such as EventEmitter in NodeJS
Emitters with addEventListener and removeEventListener methods such
as DOM event targets like elements
Emitters with addListener and removeListener methods
Limitations: If the adapted event emitter has a method to clear all
listeners the returned Subscribable may falsely report true when
unsubscribe is called.
Adapt an event emitted by a Node EventEmitter or by a DOM event target. Adapters are useful when wanting to bridge events from a third-party library or from the DOM.
This adapter will register every listener with the event emitter, and let you use the Subscribable API to subscribe, unsubscribe, filter and iterate over events.
Three different types of event emitters are supported:
on
andoff
methods, such asEventEmitter
in NodeJSaddEventListener
andremoveEventListener
methods such as DOM event targets like elementsaddListener
andremoveListener
methodsLimitations: If the adapted event emitter has a method to clear all listeners the returned Subscribable may falsely report
true
whenunsubscribe
is called.Node EventEmitter
DOM events
DOM events can be adapted: