Comments (4)
You can send pull request for fixed issue
from immer-adapter.
I understand, and I would love to do that, but some guidance would be appreciated as for why the getState returns a draft right now.
From what I can see, the getState
returns a draft and sets the frozenState
variable, which is later on used to check if the changes need to be finalized in the setState
implementation.
However, I wonder if this is intended behaviour.
Wouldn't it be better to have a getState
and a separate getDraft
method, or something like that.
This way, the default StateContext behaviour for the getState
method wouldn't change when using immer (it would just return an immutable version of the state using immers castImmutable
or something like that). And if you do want to manipulate the state, you can use the getDraft
method, mutate away, and provide that to the setState
method, where it will continue using the same behaviour as it does now.
In order to be able to use this "new" getDraft
method, it might be wise for the apps to use the ImmutableStateContext
interface, instead of the current StateContext
interface.
I'm really interested in your thoughts about all this.
If you agree with them I'l happily create a PR attempting to do what I just described :)
from immer-adapter.
To be honest, I don’t remember why I did this)) this project was experimental and I decided that using decorators was bad and unreadable
I recommended use native produce from immer instead ngxs-labs/immer-adapter
ctx.setState(produce((state) => {
// your mutation
}));
from immer-adapter.
I have been using extensively produce(ctx, draft => { ... }) in my code and it works great but have been declared deprecated in recent built. Is it replaced by ctx.setState(produce(state) => { });
Any pitfall I should be aware when changing it?
from immer-adapter.
Related Issues (20)
- Support Immer 2.0
- Is the documentation example incorrect? HOT 1
- Error: TypeError: 'ownKeys' on proxy: trap result did not include 'scope' HOT 18
- Error: Cannot read property 'ctx' of undefined HOT 4
- immer 3.0.0 compatible? HOT 1
- @ImmutableContext() doesn't work with Receiver() properly HOT 9
- Can't reset state returning 'defaults' or an object with the type of the state HOT 3
- When state is null/undefined ImmutableSelector/ImmutableContext stops working. HOT 11
- Calling isDevMode() breaks production builds HOT 1
- not working with dynamic selector HOT 3
- Immer patches and inverse patches
- Documentation typo? HOT 2
- Updating Reactive Form in State HOT 2
- Peer Dependency Support for angular v9 & v10 HOT 1
- dispatch in state
- Release for security patch HOT 1
- Angular 12 HOT 9
- Do we still need immer and this adapter when we have State Operators? HOT 2
- Project won't update on npm?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immer-adapter.