Deterministic update batching
experimental
Compare automatic microtask batching, explicit batches, and synchronous commits.
Live example
Expected behavior
One batch yields one render and one commit announcement. Replaying its commands reproduces the state hash.
Source
api.batch(() => {
api.setPipeline({ filterText: { columnId: 'name', text: 'product' } });
api.setSort([{ columnId: 'price', direction: 'desc' }]);
});
api.flush();api.batch(() => {
api.setPipeline({ filterText: { columnId: 'name', text: 'product' } });
api.setSort([{ columnId: 'price', direction: 'desc' }]);
});
api.flush();api.batch(() => {
api.setPipeline({ filterText: { columnId: 'name', text: 'product' } });
api.setSort([{ columnId: 'price', direction: 'desc' }]);
});
api.flush();api.batch(() => {
api.setPipeline({ filterText: { columnId: 'name', text: 'product' } });
api.setSort([{ columnId: 'price', direction: 'desc' }]);
});
api.flush();// JavaScript interop module
api.batch(() => {
api.setPipeline({ filterText: { columnId: 'name', text: 'product' } });
api.setSort([{ columnId: 'price', direction: 'desc' }]);
});
api.flush();API reference
| Kind | Name | Type | Description |
|---|---|---|---|
| Method | batch | — | Combines synchronous nested changes and rolls back on failure. |
| Method | flush | — | Commits queued changes outside an active explicit batch. |
| Event | batch:committed | — | Reports the version, mode and number of changed operations after other events. |