Comments (7)
The reason that's done is due to change detection in libraries/frameworks. In Angular for example, without cloning the dispatched object the object reference wouldn't change so the UI wouldn't know to update without manual coding.
While the deepCloneState value could be passed into the dispatchState function, that could potentially break previous behavior in existing apps using the library so I'm hesitant to change that functionality right now.
from observable-store.
Maybe adding a global setting which wouldn't break existing behavior and needs to be enabled manually?
I'm using it a bit like redux and create new object references before passing them to setState. Change detection seems to work fine even without deep cloning.
I think deep cloning can also be problematic if performance is important for a specific use case.
from observable-store.
I don't want to add any additional properties at this point (trying to keep the API as basic as possible....which is proving challenging to do over time :-)). While I don't have the bandwidth to implement the change right now to stop cloning during a dispatch (when deepCloneState is false), let me think it over more. I suspect it won't impact many (if any) people but I'm always careful there.
If you end up having time to submit a PR that modifies that behavior to fit what you need I'm happy to consider that as well and run it through some scenarios I have when I get some time next week.
from observable-store.
Yep, I understand it's hard to keep things simple :-)
I'll also think about this a bit more and submit my suggestion as a merge request (I'm already using a patched version of the lib for our app).
from observable-store.
That sounds great. I'll definitely give that more consideration because I kind of feel that if someone set deep cloning to false then the dispatch shouldn't need to deep clone given that they knew what they were doing when they set it to false.
If you're able to submit a PR for what you've modified for your scenario I'll look it over more. Thanks!
from observable-store.
Hi @fifafu. You're probably tied up with other things I know but if you get a chance to submit a PR with the changes you wanted let me know. Happy to look at it and see the impact on existing usage.
from observable-store.
Going to close this for now but feel free to re-open if you get a chance to submit the code you mentioned.
from observable-store.
Related Issues (20)
- Replay Subject for edge cases HOT 4
- Why won't a getter from a service/state work after any store changes? HOT 6
- Missing properties after setting state HOT 8
- Weird store structure when using stateSliceSelector HOT 2
- Store structure: Flat vs Complex + stateWithPropertyChanges returns function if that's what was passed in the setState HOT 1
- This lib can be performance problems HOT 1
- It would help so much if you included a fully working react example HOT 2
- Using state in synchronous manner HOT 1
- SetState method is not working HOT 9
- Rx.js 7.2 migration and compatibility? HOT 4
- Using JSONPath and Observable store HOT 4
- Setting State via SetState for one property HOT 4
- CommonJS or AMD dependencies can cause optimization bailouts. HOT 3
- How can I access the Observable-store data through the `window` object? HOT 3
- Problem with ReduxDevToolsExtension under electron environment HOT 5
- Losing Class (getters/setters) when returning object from store HOT 1
- setState() does not update property when setting to undefined HOT 1
- How to store n number of propertes (making the state properties dynamic) HOT 1
- is it possible to filter by Action? HOT 1
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 observable-store.