An observable value, as a zero-argument callable with extra methods.

In addition to being callable, signals also offer a .value getter, and implement the standard JS methods .toString(), .valueOf(), and .toJSON() in such a way that they reflect the signal's contents rather than the signal itself.

Signals also implement the Source interface, and can thus be subscribed to. Subscribers receive the current value first, and then any changes thereafter. They can be waited on by until(), in which case the calling job resumes when the signal's value is truthy.

You can also transform a signal to a Writable by calling its .withSet() method, or create a writable value using value().

interface Signal<T> {
    asReadonly(): Signal<T>;
    peek(): T;
    value: T;
    withSet(set: ((v: T) => unknown)): Writable<T>;
    (sink: Sink<T>, conn?: Connection, inlet?: Throttle | Inlet): "uneventful/is-stream";
    (): T;
}

Type Parameters

  • T

Hierarchy (view full)

Reading

Writing

Reading

  • Get the signal's current value, without adding the signal as a dependency

    (This is exactly equivalent to calling peek(signal), and exists here mainly for interop with other signal frameworks.)

    Returns T

value: T

The current value

Writing

  • New writable signal with a custom setter

    Parameters

    • set: ((v: T) => unknown)
        • (v: T): unknown
        • Parameters

          Returns unknown

    Returns Writable<T>