Class Signal<T>

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

Type Parameters

  • T

Hierarchy (view full)

Constructors

Properties

Methods

Constructors

  • Type Parameters

    • T

    Parameters

    • compute: Computation<T>

      A function that calculates the signal value and returns it.

    • Optionaloptions: SignalOptions<T>

      Signal options.

    Returns Signal<T>

    A computed signal.

Properties

value: T

The current value of the signal.

Methods

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

    Type Parameters

    • I extends boolean

    Parameters

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

      A function subscribed to updates.

    • Optionalimmediate: I

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

    Returns (() => void)

    An unsubscribe function.

      • (): void
      • Returns void