cefn / lauf

Monorepo for lauf packages.
MIT License
5 stars 0 forks source link

Add `store` argument to editor #141

Open cefn opened 3 years ago

cefn commented 3 years ago

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.