Batching
batch(fn) defers effects until the outermost batch ends, then flushes synchronously.
batch(fn) defers effects until the outermost batch ends, then flushes synchronously. Reads inside a batch are fresh. If fn throws, the effects still flush and the error is rethrown afterward.
flushSync(fn) is batch that also drains effects that were already pending, and returns what fn returns.