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>;
    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

  • get value(): T
  • The current value

    Returns T

  • set value(val: T): void
  • Set the current value

    Parameters

    • val: T

    Returns void

Writing

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