-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Enforce immutabillity #546
Comments
This is a common request, so I'll try to figure out a way to assemble an API to do this. Perhaps Doing so comes with the direct tradeoff that immutable collection of pointers to mutable values would not be possible. Definitely not what we want for the only behavior as this sort of thing is pretty common, but I also understand the desire to enforce strictness and throw errors if trying to put a non-immutable value into an Immutable.js collection. |
This feature would be great, i've seen quite a few people struggle with this. Once people get the idea of immutable js they expect everything you get out of a immutable data structure to be immutable.
I'm not sure adding a whole load more types is the best way to do this.
How about
Strict throws an exception if you attempt to add a non immutable object and deep does what fromJS does. |
#473 seems related, btw. |
Thanks, I'll keep considering ways to do this nicely. It's a careful line to walk between supporting generic collections and supporting deep values. |
With as useful as it is to
|
@AsaAyers I'll be happy to explicitly convert strict collections to non strict or mutable collections when I need to. For me strong immutable guarantees are more important than speed. Anyway, it would be great to have this choice. |
Closing - see #473 |
At the moment it is quite easy to push mutable objects into immutable structures, e.g.
http://jsbin.com/wiyeju/7/edit?html,js,console
I would expect something like this to either: throw an error or make the pushed object immutable automatically. It would be great if Immutable.js could provide stronger immutable guarantees.
The text was updated successfully, but these errors were encountered: