Class WritableSignal<T>

The most basic form of a signal which is just a container for a value providing read and write access to the value and allowing to monitor the value for changes by subscribing to it.

Type Parameters

  • T = unknown

Hierarchy (View Summary)

Constructors

Methods

  • Sets a new value. If the new value does not equal the old value then subscribers are informed about the change. By default values are compared with Object.is() but this behavior can be changed by specifying a custom equals method when creating the signal.

    Parameters

    • value: T

      The new value to set.

    Returns this

  • Parameters

    • ...args:
          | [Observer<T>]
          | [
              (value: T) => void,
              error?: (error: Error) => void,
              complete?: () => void,
          ]

    Returns Unsubscribable

  • Updates the value. This calls the given updater function with the current value and then just calls set with the value returned by the updater function.

    Parameters

    • updater: (currentValue: T) => T

      The function to call with the current value and which must return the new value.

    Returns this