Hello, I'm using the connect-mixin.js. I had a problem where updates in the redux store didn't persist to the underlying cache. It turns out that the stateChanged method gives back the redux state object directly (without doing a deep copy). So when the state is directly modified, the redux object is also modified, bypassing all reducers.
In my case this resulted that when the reducer was called, the values in the store were the same as in the action of the reducer. Redux-persist therefore didn't update the cache, because no changes were found.
I think it would be better if stateChanged gives back a deep copy (JSON.parse(JSON.stringify(data)). Since redux is a immutable data store, where only the reducers can alter the state, I don't expect that mutating a value from a observer would manipulate the state directly.
A simple example
_stateChanged(state)
{
let myUser = state.user;
//redux internal state object is also mutated by this
myUser.name = 'otherName';
}
Hello, I'm using the connect-mixin.js. I had a problem where updates in the redux store didn't persist to the underlying cache. It turns out that the stateChanged method gives back the redux state object directly (without doing a deep copy). So when the state is directly modified, the redux object is also modified, bypassing all reducers.
In my case this resulted that when the reducer was called, the values in the store were the same as in the action of the reducer. Redux-persist therefore didn't update the cache, because no changes were found.
I think it would be better if stateChanged gives back a deep copy (JSON.parse(JSON.stringify(data)). Since redux is a immutable data store, where only the reducers can alter the state, I don't expect that mutating a value from a observer would manipulate the state directly.
A simple example