-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronization? #54
Comments
I don't think the changes feed is been listened to. You should checkout redux-pouchdb, it is simpler than this but may suits your needs. |
This advice causes to install and depend on whole pouchDB library @aij did you found satisfying solution? |
HI @aij, You're right; the behaviour you describe is indeed what I would expect to happen. I hadn't considered this use case/scenario before, my first reaction would be to write a piece of middleware that listens to the 'storage' event and dispatch those changes to update the store state of the other tab(s). Your reducer(s) would consequently determine how to merge these changes. Is this something you considered? Are there issues you run into with this approach? |
I think this improvement should be considered essential for the library. Otherwise, it's limited to a very few use cases, and you basically cannot use it for storing auth tokens for instance. |
FWIW, I ended up using redux-persist with redux-persist-crosstab, and handling the the REHYDRATE action explicitly to merge the changes in my reducer. I also had to work around an infinite loop in IE. |
@aij thanks, that helped. We just implemented the same approach, exactly what we needed. |
I was wondering how this library handles synchronization. It would appear the answer is that it doesn't, but please correct me if I'm wrong. (In which case, documentation would be nice. :) )
For example, with two tabs using localStorage, each tab will read from localStorage when the middleware is initialized, after which point they will blindly write over each other's writes. (So, whichever tab writes last wins, and the data is not synchronized to the other tab until the app is reloaded.)
The text was updated successfully, but these errors were encountered: