fork() function allows you to create speculative state updates that happen in parallel, which can later be committed or discarded. This is useful for prefetching data or preparing UI changes in advance.
Import
Signature
Parameters
A function that performs state updates within the fork
Returns
An object with methods to commit or discard the forked state
Usage
Prefetching data
Speculative UI updates
Notes
- Forks must be created outside of any existing batch
- State changes within a fork are isolated until committed
- Multiple forks can exist simultaneously
- Requires experimental async mode