Class Variable<V>

An aggregate helper class for widgets that contain a variable with a specified type which is intended to be controlled by the user.

Useful for implementing widgets such as sliders, checkboxes, text input, etc...

Type Parameters

Hierarchy (view full)

Implements

Constructors

Properties

Accessors

Methods

Constructors

Properties

_value: V

The current value, for internal use.

callbacks: ObservableCallback<V>[] = ...

The function callbacks called when the value is changed

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

  • 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>
    • 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