RFC: Provide option for strict immutability of selectors's output #3086
samuelfernandez
started this conversation in
Ideas
Replies: 4 comments 3 replies
|
Putting this on my radar to possibly work on |
0 replies
|
If you give me some guidance and green light I'm willing to try and submit a PR |
0 replies
|
Thanks @samuelfernandez and @david-shortman. We will give some guidance. Don't start on any work on this just yet |
2 replies
|
Should return values be immutable as a best practice? Specifically talking about derived values that are transformed from store state that is already in the reducer. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
It is great that the store returns an immutable JS object, which helps in finding bugs in case the state was modified outside of the reducer by mistake. Lately, this has become a core part of the framework, including actions, which is nice.
However, we also have selectors. I have faced the problem of mistakenly modifying an object coming from a selector, which caused undesirable side-effects.
It might be nice that the results of
createSelectorwere made immutable at the output to make sure they are not modified, since eventually a selector is an extension of the store's data. This could be a breaking change for some apps, so maybe it could just be an opt-in option in the root settings, or an option at eachcreateSelectorDescribe any alternatives/workarounds you're currently using
Be a good programmer and avoid going evil
If accepted, I would be willing to submit a PR for this feature
[x] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
All reactions