Class ValidatedVariable<V, T>

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

Type Parameters

Hierarchy (view full)

Implements

Constructors

Properties

_valid: boolean = true

See ValidatedVariable#valid. For internal use only

_validValue?: T

See ValidatedVariable#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 ValidatedVariable#validValue will be equal to Variable#value.

Accessors

  • get value(): V
  • The current value.

    If setting, Variable#setValue is called with no group.

    Returns V

  • set value(value): void
  • 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.

    Parameters

    • value: V

    Returns void

Methods

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

    Parameters

    • callback: ObservableCallback<V>
    • callNow: boolean = false

      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