Interface Signal<T>

A basic reactive primitive. Notifies consumers of a change in the stored value and triggers them to recalculate.

interface Signal<T> {
    get(track?): T;
    subscribe<E>(subscriber, exec?): (() => void);
}

Type Parameters

  • T

Hierarchy (view full)

Methods

Methods

  • Calculates and returns the current value of the signal.

    Parameters

    • Optional track: boolean

      Determines whether the signal should be tracked as a dependency. Default is true.

    Returns T

  • Subscribes the passed function to updates of the signal value.

    Type Parameters

    • E extends boolean

    Parameters

    • subscriber: Subscriber<true extends E
          ? T
          : Exclude<T, undefined>>

      A function subscribed to updates.

    • Optional exec: E

      Determines whether the function should be executed immediately after subscription. Default is true.

    Returns (() => void)

    An unsubscribe function.

      • (): void
      • Returns void

Generated using TypeDoc