Dispatch REDUX_STORAGE_SAVE only when state has been really changed. #144
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MichaelContento/redux-storage#144
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From developer experience, it really makes sense to not dispatch REDUX_STORAGE_SAVE when nothing has been changed.
Update Engine save?
I also like the idea but it would require a deep comparision of the state which might be a bit difficult, as the user free to put immutablejs or any other non-plain-old-javascript-object in the state.
Not at all.
https://github.com/facebook/immutable-js#converts-back-to-raw-javascript-objects
And if the user puts inside a object with circular references, it will fail anyway.
I'm not saying it's impossible to implement 😃
We also should think about where to add this check. Currently the middleware (see here) is will trigger the action after
engine.saveresolves. If we add this check before callingengine.savewe also skip the whole engine-decorator stack (which might be expensive too), butredux-storage-decorator-filterfor example could increase the "skip save hitrate".I just discovered this issue myself and found that it results in, naturally, all of my
connected components re-rendering, which in turn re-renders my stateless functional components (as they lack the componentShouldUpdate check). This has resulted in a noticeable slowdown in the rendering performance of my react native app.Are you aware of any work-arounds to this that can help alleviate the performance impact of the overly chatty REDUX_STORAGE_SAVE?
Your
connected components should only re-render as soon as the state changes.REDUX_STORAGE_SAVEis, on its own, just a simple action and does not change the state itself. So as long as you don't process and modify the save action, the state keeps the same and no component should start re-rendering.Can you provide us some example code to illustrate this behaviour?
Ah, well, thanks for the intel! Perhaps I have some other odd behavior going on! Let me do some investigation on my end and I'll check back when I know more.
Just to be clear, would you expect the mapStateToProps and mapDispatchToProps functions to execute as the result of the message, or you're saying they shouldn't execute unless the redux store itself has been modified?
How can i trigger saving engine in custom http request file outside the component?
Scene: User had logined in app, however the server tell client that the user is not login, so i should change the localstorage.
Apologize for my poor english.
Sorry, i have known what i need, just use store function(dispatch actions) outside components.
Sorry for the bad news but this package is no longer maintained. 😞
My focus has left the react / node ecosystem and I don't have to time to keep things up to date. But if you want to step in and become the new maintainer of
redux-storageand all of it parts, just ping me! 😃