Closed beckend closed 7 years ago
This question has little to do with redux-immutable
itself and more with https://github.com/facebook/immutable-js/.
Regardless, it is an interesting issue, one that I did not even realise I have. : )
Quick Google search brought me to https://www.npmjs.com/package/transit-immutable-js
And thats http://blog.cognitect.com/blog/2014/7/22/transit an intro to Transit data interchange format.
This looks like a reasonable solution.
@beckend I would appreciate if you'd share your findings with others. Can you raise a PR?
Same issue when serializing a Immutable.Set
on the server and deserialize for hydratation on client, it becomes an Immutable.List
.
Ill try the provided packages
@kandros I have suggested a fix. Is it still an issue?
For the record, I have been using transit-immutable-js in production for a while now. There are no downsides to it, other than a relatively large bundle size addition.
Let's say I have a reducer with initialState:
myReducer
Then time to save to local store:
Then to restore it:
Then the reducer has been restored, but as a
Immutable.List
because ofImmutable.fromJS
:Is there a good solution to retain the immutable types somehow?