Saltar al contenido principal

Function: useCreateBatch()

useCreateBatch(): (callback) => void

Defined in: src/core/services/reactive.service.ts:334

Returns a batch function that defers signal notifications until the callback completes. Nested calls are supported -- only the outermost batch flushes the queue.

Returns

A batch(callback) function.

(callback) => void

Example

const batch = useCreateBatch();
const [a, setA] = useCreateSignal(0);
const [b, setB] = useCreateSignal(0);

batch(() => {
setA(1);
setB(2);
// listeners fire only once here, not twice
});