Implement direct mutation support?
See original GitHub issuePosted this initially to #10 but it’s offtopic over the so I’m pulling it here.
Have you considered supporting mutating the state too? I think this method could be used to implement very mobx like api for Redux.
Eg. add support for this:
function Counter() {
const state = useReduxState();
return <button onClick={() => state.count++}>{count}</button>;
}
The implementation could go like this:
- User does
state.foo.bar = 1
in a event handler- it should be banned during the render tick
- Record that change as a immer patch
{"op": "replace", "path": ["foo", "bar"], "value": 1}
- Create redux action from like
{
type: "IMMER_PATCH",
patch: {"op": "replace", "path": ["foo", "bar"], "value": 1},
}
- And apply it using
applyPatches
from immer in a reducer. It would support all the redux goodies: Devtools, Time-travel, action serialization etc.
Kinda getting excited about this 😃
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Direct mutation analysis by high-throughput sequencing - NCBI
Although the PacBio RS instrument could help identify germline structural variants as a supplement to a whole genome run with the Illumina or ......
Read more >Practical use cases for AWS AppSync Pipeline Resolvers
We demonstrate how a direct Lambda resolver can be bound to both Mutation and Query fields, and how we can still use a...
Read more >Mutate Resources | Kyverno
A JSON Patch, implemented as a mutation method called patchesJson6902 , provides a precise way to mutate resources and supports the following ...
Read more >Circulating tumour DNA analysis to direct therapy in advanced ...
Interpretation ctDNA testing offers accurate, rapid genotyping that enables the selection of mutation-directed therapies for patients with ...
Read more >Mutations | Vuex
You cannot directly call a mutation handler. ... It is a commonly seen pattern to use constants for mutation types in various Flux ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/theKashey/memoize-state/issues/26 - the only limitation so far. We likely have a solution for spreads.
immer
is working like a magic. ButThis is something every new comer want, this is something every author of a brand new state management library want to introduce.
This is something I dont like to have. Idea is to separate actions and changes. To move side effects to
sagas
, to respond to one action from multiple reducers, to have easy way to debug and easy way to reason about.Something like teaming Redux and useReducer - might be cool, but also catastrophic.
From another point of view - yes, this could be done.