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
Currently it is quite annoying to grab the patches from a producer, for two reasons:
First, directly returning is often impossible, and a lot of temporarily local vars enter the game, in order to be able to wire up the receiving both the next state and the patches. The following pattern I encounter quite reqularly:
constmyCoolFunc(state)=>produce(state,draft=>{/* something */})// to capture patches, it must be destructred to :// (this is even worse if you used a curried produce, as it has to be uncurried to be able to write the following)constmyCoolFuncWithPatches(state)=>{letpatchesconstnextState=produce(state,draft=>{/* something */},p=>{patches=p})return[nextState,patches]}// with this proposal it becomesconstmyCoolFunc(state)=>produceWithPatches(state,draft=>{/* something */})
馃殌 Feature Proposal
Introduce API's to capture the next state and patches directly:
produceWithPatches(baseState, recipe) => [nextState, patches, inversePatches]
produceWithPatches(recipe) => (baseState, ...args) => [nextState, patches, inversePaches]
(curried form)Motivation
Currently it is quite annoying to grab the patches from a producer, for two reasons:
First, directly returning is often impossible, and a lot of temporarily local vars enter the game, in order to be able to wire up the receiving both the next state and the patches. The following pattern I encounter quite reqularly:
cc @aleclarson
The text was updated successfully, but these errors were encountered: