Value accessor and changes tracker.

Implements an EventSender interface by sending value changes to registered receivers as a pair of new and old values.

Implements an EventKeeper interface by sending current value and its updates.

Type Parameters

  • T

    Tracked value type.

Hierarchy

Implements

Constructors

Properties

_by: Supply = ...
it: T

The tracked value.

on: OnEvent<[T, T]>

OnEvent sender of value changes.

The [OnEvent__symbol] property is an alias of this one.

Returns

Value changes sender.

read: AfterEvent<[T]> = ...

AfterEvent keeper of current value.

The [AfterEvent__symbol] property is an alias of this one.

Returns

Current value keeper.

supply: Supply

An event supply of this value tracker.

Methods

  • Updates the tracked value by the given value supplier.

    If the value is already updated by another supplier, then unbinds from the old one first.

    Call the byNone method to unbind the tracked value from the source.

    Note that explicitly updating the value would override the value received from the source.

    Parameters

    • supplier: EventSupplier<[T]>

      The source value sender or keeper.

    Returns ValueTracker<T>

    this instance.

  • Updates the tracked value by value suppliers extracted from events sent by the given supplier.

    If the value is already updated by another value supplier, then unbinds from the old one first.

    Call the byNone method to unbind the tracked value from the source.

    Note that explicitly updating the value would override the value received from the source.

    Type Parameters

    • TSrcEvent extends any[]

      Source event type.

    Parameters

    • supplier: EventSupplier<TSrcEvent>

      The event supplier to extract value suppliers from.

    • extract: ((this, ...event) => undefined | EventSupplier<[T]>)

      A function extracting value supplier from event received from supplier. May return undefined to suspend receiving values.

        • (this, ...event): undefined | EventSupplier<[T]>
        • Parameters

          • this: void
          • Rest ...event: TSrcEvent

          Returns undefined | EventSupplier<[T]>

    Returns ValueTracker<T>

    this instance.

Generated using TypeDoc