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
function save(key, op) {
return async (state) => {
const data = state.data // save the incoming state
const result = await(op(state))
state[key]=result;
state.data = data;
return state;
}
}
I like this because it's quite natural language-y. It would be better to do like get(something).as(key), but the as function would have no means to restore the prior state. The get would just blat it. References would be a workaround but we can't guarantee it will have written.
josephjclark
changed the title
common: add something like a save() function
common: add something like a save() or as() function
Oct 30, 2024
A common use case is to run an operation and then to save the result back to state on a key other than data
Like this:
This is really quite painful.
What if we had a wrapper operation that was able to take any state.data object and proxy/alias/push it to some other key:
The implementation is something like this:
I don't like name though. Some ideas:
The text was updated successfully, but these errors were encountered: