Ref.modify for read-and-update
Use `Ref.modify(ref, fn)` when you need to read and update atomically. The function receives the current value and returns `[newValue, result]`—the Ref is set to `newValue`, and the Effect succeeds with `result`.
- Use `Ref.modify(ref, (current) => [newValue, result])`
- Returns the `result`; Ref is set to `newValue`
- Atomic: no other fiber can interrupt between read and write
Loading code editor...