You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Immer is a library that allows a developer to work on a draft of state instead of recreating the state for each handled action.
An example of a reducer:
importproducefrom"immer"constbaseState=[{todo: "Learn typescript",done: true},{todo: "Try immer",done: false}];constnextState=produce(baseState,draftState=>{draftState.push({todo: "Tweet about it"})draftState[1].done=true});
It would be nice to support this in safe-redux. The changes are quite simple, but the major question is how we support that inside this package. for example, an immer implementation of Handler could be changed to:
Where we introduce the draft that is mutable and part of immer. At the same time, we need to have an implementation of handleActions that looks something like this:
Interesting question. I'm aware of Immer, but haven't used it myself.
I'm not sure if adding Immer support is the best idea. This library is pretty basic, if you remove the types you have just a few lines of code. And we'd like to keep it that way.
Maybe you can fork it and publish it on your own? E.g. safe-redux-immer.
If you do that, please let me know so I can update the README and point to it for those looking to use Immer.
Immer is a library that allows a developer to work on a draft of state instead of recreating the state for each handled action.
An example of a reducer:
It would be nice to support this in safe-redux. The changes are quite simple, but the major question is how we support that inside this package. for example, an immer implementation of
Handler
could be changed to:Where we introduce the draft that is mutable and part of immer. At the same time, we need to have an implementation of handleActions that looks something like this:
The text was updated successfully, but these errors were encountered: