turbodombuilder - v0.9.22
    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.

      • Optionalkey: PropertyKey

        The key 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.

      // Standalone signal
      const count = signal(0);
      // e.g., count.get(), count.set(1)
    • Function

      signal

      Type Parameters

      • Value

      Parameters

      • Optionalget: () => Value

        Getter that returns the value.

      • Optionalset: (value: Value) => void

        Setter that changes the value and emits the signal.

      • Optionaltarget: object

        The target to which the signal is bound.

      • Optionalkey: PropertyKey

        The key 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.

      // Standalone signal
      const count = signal(0);
      // e.g., count.get(), count.set(1)
    • 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