Interface Box<V>

Generic value holder interface that can be observed.

interface Box<V> {
    value: V;
    setValue(value: V, group?: unknown): boolean;
    unwatch(callback: ObservableCallback<V>): this;
    watch(callback: ObservableCallback<V>, callNow?: boolean, group?: unknown): this;
}

Type Parameters

Hierarchy (view full)

Implemented by

Properties

Methods

Properties

value: V

The current value.

When the value is set via this setter, the class implementing this interface should notify the observable with no group (undefined). Note that this is just a suggestion, not a strict requirement.

Methods

  • Sets Box#value. Does nothing if the value is already the one specified.

    Parameters

    • value: V
    • Optionalgroup: unknown

      The observable group that this change belongs to. undefined by default.

    Returns boolean

    Returns true if the value was changed, false if not

  • Register a callback to this observable. When the value is changed, the callback will be called.

    Parameters

    • callback: ObservableCallback<V>
    • OptionalcallNow: boolean

      If true, the callback will be called once immediately after it's registered. False by default

    • Optionalgroup: unknown

      The group to use when calling immediately. Only used if callNow is true, and is undefined by default

    Returns this