A concrete implementation of ISignal.
ISignal
import { ISignal, Signal } from '@lumino/signaling';class SomeClass { constructor(name: string) { this.name = name; } readonly name: string; get valueChanged: ISignal<this, number> { return this._valueChanged; } get value(): number { return this._value; } set value(value: number) { if (value === this._value) { return; } this._value = value; this._valueChanged.emit(value); } private _value = 0; private _valueChanged = new Signal<this, number>(this);}function logger(sender: SomeClass, value: number): void { console.log(sender.name, value);}let m1 = new SomeClass('foo');let m2 = new SomeClass('bar');m1.valueChanged.connect(logger);m2.valueChanged.connect(logger);m1.value = 42; // logs: foo 42m2.value = 17; // logs: bar 17 Copy
import { ISignal, Signal } from '@lumino/signaling';class SomeClass { constructor(name: string) { this.name = name; } readonly name: string; get valueChanged: ISignal<this, number> { return this._valueChanged; } get value(): number { return this._value; } set value(value: number) { if (value === this._value) { return; } this._value = value; this._valueChanged.emit(value); } private _value = 0; private _valueChanged = new Signal<this, number>(this);}function logger(sender: SomeClass, value: number): void { console.log(sender.name, value);}let m1 = new SomeClass('foo');let m2 = new SomeClass('bar');m1.valueChanged.connect(logger);m2.valueChanged.connect(logger);m1.value = 42; // logs: foo 42m2.value = 17; // logs: bar 17
Construct a new signal.
The sender which owns the signal.
Readonly
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 and invoke the connected slots.
The args to pass to the connected slots.
Slots are invoked synchronously in connection order.
Exceptions thrown by connected slots will be caught and logged.
A concrete implementation of
ISignal
.Example