Class ValidatedVariable<V, T, C>

Similar to Variable, except the variable's value can optionally be validated by a validator function.

Type Parameters

Hierarchy

Constructors

Properties

_valid: boolean = true

See valid. For internal use only

_validValue?: T

See validValue. For internal use only

validator: null | Validator<V, T>

The validator/transformer used for this variable's value. If null, then the value will always be valid and validValue will be equal to value.

Accessors

Methods

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

    Returns

    Returns true if the value was changed, false if not

    Parameters

    • value: V
    • notify: boolean = true

      If true, then the callbacks are called.

    Returns boolean

  • Unregister a previously registered callback from this variable.

    Parameters

    • callback: C

    Returns boolean

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

    Parameters

    • callback: C
    • callNow: boolean = true

      If true, the callback will be called once immediately after it's registered, unless the callback is already registered.

    Returns boolean

Generated using TypeDoc