rt2zz / redux-persist-immutable

Redux Persist Immutable
MIT License
114 stars 31 forks source link

Check state are `Immutable` for operators #9

Open jhen0409 opened 7 years ago

jhen0409 commented 7 years ago

I have some non-immutable object in state (like routerReducer of react-router-redux), when I using redux-persist-immutable, it will throw state.forEach is not function error. I think we should use Iterable.isIterable() to check state are Immutable.

rt2zz commented 7 years ago

Firstly I agree, we should handle non-immutable state. As you mentioned this should be as simple as checking isIterable() in a couple of places in our operators.

Secondly, I am a bit confused that you are receiving that error. This module only checks top level state, and the shape of the state of your sub-reducers (react-router-redux for example) should not have any bad interactions. Can you double check that your top level state is an immutablejs Map, or clarify if i misunderstand something?

jhen0409 commented 7 years ago

This module only checks top level state, and the shape of the state of your sub-reducers (react-router-redux for example) should not have any bad interactions.

Yes, sorry, I misunderstood. 😂

Can you double check that your top level state is an immutablejs Map

My top level state isn't an immutablejs Map, I just used it in sub-state, that's work with old version redux-persist-immutable.

rt2zz commented 7 years ago

Ah yes, I wish we had a better naming scheme around this. You probably want https://github.com/rt2zz/redux-persist-transform-immutable plugged in to vanilla redux-persist. In the near future I will add non-immutable top level state support to this project which I think should help alleviate some of the confusion.