turbodombuilder - v0.9.66
    Preparing search index...

    Function signal

    • Function

      signal

      Type Parameters

      • Value

      Parameters

      • Optionalinitial: Value

        Initial value stored by the signal.

      • Optionaltarget: object

        The target to which the signal is bound.

      • ...keys: KeyType[]

        The key path at which the signal will be stored in the target.

      Returns SignalBox<Value>

      A reactive box for reading/updating the value.

      Create a standalone reactive signal box. Returns a SignalBox wrapping the initial value.

      const count = signal(0);
      const nested = signal(0, target, "users", "42", "score");
    • Function

      signal

      Type Parameters

      • Value

      Parameters

      • get: () => Value

        Getter that returns the value.

      • set: (value: Value) => void

        Setter that changes the value and emits the signal.

      • Optionaltarget: object

        The target to which the signal is bound.

      • ...keys: KeyType[]

        The key path at which the signal will be stored in the target.

      Returns SignalBox<Value>

      A reactive box for reading/updating the value.

      Create a standalone reactive signal box that mirrors a getter and a setter. Returns a SignalBox wrapping the initial value.

      const nested = signal(() => target.get("users", "42"), v => target.set(v, "users", "42"), target, "users", "42");
      
    • Function

      Type Parameters

      • Type extends object
      • Value

      Parameters

      • value:
            | ((initial: Value) => Value)
            | ((this: Type) => Value)
            | ((this: Type, v: Value) => void)
            | { get?: (this: Type) => Value; set?: (this: Type, value: Value) => void }
      • context:
            | ClassFieldDecoratorContext<Type, Value>
            | ClassGetterDecoratorContext<Type, Value>
            | ClassSetterDecoratorContext<Type, Value>
            | ClassAccessorDecoratorContext<Type, Value>

      Returns any

      signal

      Stage-3 decorator that turns a field, getter, setter, or accessor into a reactive signal.

      class Counter {
      @signal count = 0;

      @effect
      log() { console.log(this.count); }
      }

      const c = new Counter();
      c.count++; // triggers effect, logs updated value