turbodombuilder - v0.9.22
    Preparing search index...

    Function effect

    • Function

      effect

      Parameters

      • callback: () => void

        The callback to process.

      Returns () => void

      A callback that, once called, disposes of the created effect.

      Bind a standalone effect callback to any signal it includes. The callback will be fired everytime the signal's value changes.

      const count = signal(0);
      effect(() => console.log(count.value));
    • Function

      Type Parameters

      • Type extends object

      Parameters

      • value: ((this: Type) => void) | (() => void)
      • Optionalcontext:
            | ClassMethodDecoratorContext<Type, any>
            | ClassGetterDecoratorContext<Type, any>
            | ClassFieldDecoratorContext<Type, any>

      Returns any

      effect

      Stage-3 decorator that turns a function or getter into an effect callback bound to any signal it includes. The callback will be fired everytime the signal's value changes.

      class Counter {
      @signal count = 0;

      @effect log = () => console.log(this.count);
      }

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