A concrete implementation of IStream.
IStream
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 alpham1.ping('beta'); // logs: connect beta // logs: iterator beta Copy
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 alpham1.ping('beta'); // logs: connect beta // logs: iterator beta
Construct a new signal.
The sender which owns the signal.
Private
Readonly
Return an async iterator that yields every emission.
Connect a slot to the signal.
The slot to invoke when the signal is emitted.
Optional
The this context for the slot. If provided, this must be a non-primitive object.
this
true if the connection succeeds, false otherwise.
true
false
Disconnect a slot from the signal.
The slot to disconnect from the signal.
true if the connection is removed, false otherwise.
Emit the signal, invoke the connected slots, and yield the emission.
The args to pass to the connected slots.
Stop the stream's async iteration.
A concrete implementation of
IStream
.Example