Cell updates
It's easy to update cells depending on their previous value:
const counter = proxy.new(0);
// ...
counter.update((prev) => prev + 1);
Note that update
functions should return new arrays and objects, for
instance using spread operators [...prev, new]
and {...prev, field: new}
.
If you need more complex imperative updates, we suggest you to use immer:
import { produce } from "immer";
const patch = (prev) => {
// complex updates...
};
cell.update((prev) => produce(prev, patch));