Currently if you need to use store.write() this radically changes the signatures you adopt for state management. To avoid this, we could pass a {castDraft,store} control object as the second argument. Then if a particular editor decided to use store.write() it would be trivial without changing the signature.
To re-introduce the error-checking logic of Immer, we should probably check EITHER that the Store state has already changed after calling produce, OR that the produce function returned a changed nextState BUT NOT BOTH, since if both have produced a new object we don't know which one to use preferentially so it's an error.
Currently if you need to use store.write() this radically changes the signatures you adopt for state management. To avoid this, we could pass a
{castDraft,store}
control object as the second argument. Then if a particular editor decided to usestore.write()
it would be trivial without changing the signature.To re-introduce the error-checking logic of Immer, we should probably check EITHER that the Store state has already changed after calling produce, OR that the produce function returned a changed nextState BUT NOT BOTH, since if both have produced a new object we don't know which one to use preferentially so it's an error.