Class ObservableTransformer<V, I, U>

An Observable which transforms a list of input Observables into a single value efficiently.

Type Parameters

Implements

Constructors

  • Type Parameters

    Parameters

    • inputs: I

      The list of observables to use as inputs for this transformer.

    • transformer: ((inputs: I) => V)

      The actual transformer function. Takes in a list of input observables, and outputs a single value.

        • (inputs): V
        • Parameters

          • inputs: I

          Returns V

    • Optionaldecider: ((inputs: I) => boolean)

      Decides whether the transformer's output value needs to be updated or not. If undefined (the default), then the value is always assumed to need to be updated whenever an input watcher is invoked.

        • (inputs): boolean
        • Parameters

          • inputs: I

          Returns boolean

    Returns ObservableTransformer<V, I, U>

Properties

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

The function callbacks called when the value is changed

decider?: ((inputs: I) => boolean)

Decides whether the transformer's output value needs to be updated or not. If undefined (the default), then the value is always assumed to need to be updated whenever an input watcher is invoked.

dirty: boolean = true
inputs: I

The list of observables to use as inputs for this transformer.

transformer: ((inputs: I) => V)

The actual transformer function. Takes in a list of input observables, and outputs a single value.

watcher: null | ObservableCallback<U>

Accessors

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