An Observable which relays a value to 0 or more subscribing observers.
You may stop the wire from executing by calling .finish. The Activity returned by subscribing to it can be used to "unsubscribe" that observer from the wire.
const broadcaster = new Wire<number>();const a1 = broadcaster.subscribe({ next(n: number) { console.log("[listener 1]", n); }});const a2 = broadcaster.subscribe({ next(n: number) { console.log("[listener 2]", n); }});broadcaster.next(1);// "[listener 1] 1"// "[listener 2] 2"a1.finish();broadcaster.next(2);// "[listener 2] 2" Copy
const broadcaster = new Wire<number>();const a1 = broadcaster.subscribe({ next(n: number) { console.log("[listener 1]", n); }});const a2 = broadcaster.subscribe({ next(n: number) { console.log("[listener 2]", n); }});broadcaster.next(1);// "[listener 1] 1"// "[listener 2] 2"a1.finish();broadcaster.next(2);// "[listener 2] 2"
A Wire pushes subscribing observers into this._subscribers | an array of subscribers. The returned Activity will unsubscribe the observer.
Protected
Flag indicating whether the wire has finished execution.
Intended to be idempotent.
Type returned by the incoming observer.
This function will be called each time the observable publishes a value.
Generated using TypeDoc
An Observable which relays a value to 0 or more subscribing observers.
You may stop the wire from executing by calling .finish. The Activity returned by subscribing to it can be used to "unsubscribe" that observer from the wire.
See
Example