The function to execute while batching notifications.
const a = atom(0);
const b = atom(0);
let foo = 0;
autorun(() => {
a.value;
b.value;
foo++;
});
console.log(a.value, b.value, foo); // 0 0 1
batch(() => {
a.value++;
b.value++;
});
console.log(a.value, b.value, foo); // 1 1 2
Executes the specified function while batching notifications to reactive items. This is useful for operations that make multiple changes to reactive items, as it prevents the notifications from being sent until all changes have been made.