Creates a batch of updates. Computations within the batch are deferred until the batch completes.
The function containing updates to batch.
Optional
The value to use as this when executing fn.
this
fn
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);}); Copy
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);});
Creates a batch of updates. Computations within the batch are deferred until the batch completes.