Class Stream<T, U>

A concrete implementation of IStream.

Example

import { IStream, Stream } from '@lumino/signaling';

class SomeClass {

constructor(name: string) {
this.name = name;
}

readonly name: string;

get pings(): IStream<this, string> {
return this._pings;
}

ping(value: string) {
this._pings.emit(value);
}

private _pings = new Stream<this, string>(this);
}

let m1 = new SomeClass('foo');

m1.pings.connect((_, value: string) => {
console.log('connect', value);
});

void (async () => {
for await (const ping of m1.pings) {
console.log('iterator', ping);
}
})();

m1.ping('alpha'); // logs: connect alpha
// logs: iterator alpha
m1.ping('beta'); // logs: connect beta
// logs: iterator beta

Type Parameters

  • T
  • U

Hierarchy (view full)

Implements

Constructors

Properties

_pending: Pending<U> = ...
sender: T

The sender which owns the signal.

Methods

  • Connect a slot to the signal.

    Parameters

    • slot: Slot<T, U>

      The slot to invoke when the signal is emitted.

    • Optional thisArg: unknown

      The this context for the slot. If provided, this must be a non-primitive object.

    Returns boolean

    true if the connection succeeds, false otherwise.

  • Disconnect a slot from the signal.

    Parameters

    • slot: Slot<T, U>

      The slot to disconnect from the signal.

    • Optional thisArg: unknown

      The this context for the slot. If provided, this must be a non-primitive object.

    Returns boolean

    true if the connection is removed, false otherwise.