A writable signal that can be set to either a value or an expression.

Like a spreadsheet cell, a configurable signal can contain either a value or a formula. If you .set() a value or change the .value property of the signal, the formula is cleared. Conversely, if you set a formula with .setf(), then the value is calculated using that formula from then on, until another formula is set, or the value is changed directly again.

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

  • Set a formula that will be used to calculate the signal's value. If it uses the value of other signals, this signal's value will be recalculated when they change.

    Parameters

    • expr: (() => T)
        • (): T
        • Returns T

    Returns this