Reactive APIs
    Preparing search index...
    • Executes a set of reactive updates implemented in callback. Effects are delayed until the batch has completed.

      It is good practice to group multiple updates into a batch to prevent an excessive number of effects from triggering.

      batch returns the value of callback().

      Example:

      const r1 = reactive(1);
      const r2 = reactive(2);

      // Log r1 and r2 every time they change.
      syncEffect(() => {
      console.log(r1.value, r2.value);
      });

      // Trigger multiple updates at once.
      batch(() => {
      // these two updates don't trigger the effect yet
      r1.value = 2;
      r2.value = 3;
      });
      // now the effect runs once

      Type Parameters

      • T

      Parameters

      • callback: () => T

      Returns T