redux-persist icon indicating copy to clipboard operation
redux-persist copied to clipboard

Listening for persisting to storage completion

Open Altiano opened this issue 8 years ago • 3 comments

I'm using v4 and localForage to store the state. Looking at the source code of redux-persist I think It is trivial to add couple of lines to notified whether persisting is complete

Altiano avatar Sep 29 '17 04:09 Altiano

persisting happens all the time, is there a reason you want to be notified? Also v5 has a flush method that returns a promise which when resolved means "persist is complete", perhaps that can work for your use case?

rt2zz avatar Oct 13 '17 16:10 rt2zz

I seem to forget why I was asking this. I think it is because I need to synchronize the state between two opened tabs. Changing the state on one tab will trigger persisting, but the other wouldn't know and you'll end up with diff state between the two tabs. So, what I think would solve the problem is to have a listener on every persisting completion. With that, I could notify the other tab to load again from the storage.

Altiano avatar Oct 19 '17 11:10 Altiano

I seem to forget why I was asking this. I think it is because I need to synchronize the state between two opened tabs. Changing the state on one tab will trigger persisting, but the other wouldn't know and you'll end up with diff state between the two tabs. So, what I think would solve the problem is to have a listener on every persisting completion. With that, I could notify the other tab to load again from the storage.

I try to achieve the same thing, any update on this?

RedFish avatar Apr 24 '24 08:04 RedFish