@embra/reactivity - v0.0.7
    Preparing search index...

    Function batch

    • Creates a batch of updates. Computations within the batch are deferred until the batch completes.

      Type Parameters

      • T

      Parameters

      • fn: () => T

        The function containing updates to batch.

      • OptionalthisArg: any

        The value to use as this when executing fn.

      Returns T

      The result of the function fn.

      import { batch, writable, compute } from "@embra/reactivity";

      const count$ = writable(0);
      const double$ = compute(get => get(count$) * 2);

      batch(() => {
      count$.set(1);
      count$.set(2);
      });