A Signal with a .set() method and writable .value property.

interface Writable<T> {
    asReadonly(): Signal<T>;
    edit(patch: ((before: T) => T)): void;
    peek(): T;
    set: ((val: T) => void);
    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

  • 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

  • Update the current value with a patch function

    Note: this reads the signal's current value, which may produce a write conflict or circular dependency if you call it from inside a rule.

    Parameters

    • patch: ((before: T) => T)
        • (before: T): T
        • Parameters

          • before: T

          Returns T

    Returns void

set: ((val: T) => void)

Set the current value. (Note: this is a bound method so it can be used as a callback.)

Type declaration

    • (val: T): void
    • Parameters

      • val: T

      Returns void