4 ms·
The problem with Immutable.js is that you have to remember to convert them to regular objects to use with third-party modules that expect plain JavaScript objec
by Osiris 11y ago
The problem with Immutable.js is that you have to remember to convert them to regular objects to use with third-party modules that expect plain JavaScript objects. One way to address that is to use Object.freeze instead. There's a nice library called icepick[1] that facilitates using Object.freeze to create immutable plain objects.
[1] https://github.com/aearly/icepick https://github.com/aearly/icepick
*EDIT: Clarification
- jlongster 11y agoSounds like you just skimmed the top of the blog post.
- Osiris 11y agoI read it. I was just commenting on an alternative that uses native objects rather than custom objects.
- baddox 11y agoThe article discusses this, and mentions seamless-immutable.
- rcconf 11y agoI haven't really had an issue with this. You can use the functions .toJS(), .toArray(), .toObject() on any Immutable object to go back to a plain JavaScript object.
- 15155 11y agoImmutable Records have predefined fields that getters are created for, allowing them to be used as regular objects.