Class Wire<A>

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

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"

Type Parameters

  • A

Hierarchy (view full)

Implements

Constructors

Properties

Accessors

Methods

Constructors

Properties

_done: boolean = false
_subscribers: Observer<A, unknown>[] = []

Accessors

  • get done(): boolean
  • Flag indicating whether the wire has finished execution.

    Returns boolean

Methods

Generated using TypeDoc