import { Observable } from "./Observable"; import { IDestroyable } from "./interfaces"; import { argumentNotNull } from "./safe"; type Handler = (x: T) => void; export class ObservableValue extends Observable { private _value: T; constructor(initial: T) { super(); this._value = initial; } getValue() { return this._value; } setValue(value: T) { this._value = value; this._notifyNext(value); } on(next: Handler, error?: Handler, complete?: () => void): IDestroyable { argumentNotNull(next, "next"); try { next(this._value); } catch { // suppress error } return super.on(next, error, complete); } }