-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: ng-redux and immutable #101
Comments
Hey, Closing the issue, but let me know if that doesn't answer your questions. |
Thanks. I see that reselect is used but i don't think the example app shows a way to use immutable in PROD application. Even the comment says : |
Why don't you do like what is done in react + redux? Again, I have never used immutable.js in a prod application myself, so sorry for the dumb questions :) |
As I see how react uses immutable with redux - they try not to perform toJS expensive operation but use immutable collection in JSX. Since all immutable collections are Iterable and have filter, map... API, you can use them directly in JSX without going though very expensive toJS operation that deeply copies the whole store to plain javascript. In immutable.js if a subtree has not been changed after setIn, merge operations, immutable.js will reuse the sub-tree in a new obj. By checking the old ref with new ref you can figure out if sub-tree has been changed (like angular 2 on Push detection) and go via render only when it is needed. If we use toJS - this is completely new object and we loose benefits of immutable and the app performance gets decreased. |
Thanks for the clarification. |
@ipassynk Are you using selectors? Or reselect library? If so, just do the toJs in the selector. If you're using reselect, the toJs method will only run when there is a change to the data. So you can use immutable in your reducers but deal with POJOs in your app. |
Recently, I was playing around with ng-redux, immutable and reselect. I post the link here https://github.com/johanzhou8/ng-redux/tree/master/examples/async-immutable in case someone needs the example. |
I am using ng-redux with angular 1 application and my store does not use immutable.js at this moment. I am wondering how to make the store immutable and do affect the performance with toJS calls in the controller. I especially concert with calling toJS on each store update in mapStateToProps function. I saw the in react community people use reselect to solve similar concerns. I am wondering if reselect can be also used with ng-redux?
As alternative I am currently playing with idea to use _.memoize in my mapToState function to check if specific slice on store in immutable store has been changed. I am wondering if somebody already use immutable.js with angular 1 and how?
The text was updated successfully, but these errors were encountered: