import { pull } from 'lodash';
export class ObservableValue {
    constructor(initial) {
        Object.defineProperty(this, "value", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
        Object.defineProperty(this, "listeners", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: []
        });
        this.value = initial;
    }
    set(value) {
        if (this.value !== value) {
            this.value = value;
            this.listeners.forEach(l => l(value));
        }
    }
    get() {
        return this.value;
    }
    onChange(listener) {
        this.listeners.push(listener);
        return () => {
            pull(this.listeners, listener);
        };
    }
}
//# sourceMappingURL=ObservableValue.js.map