-
Notifications
You must be signed in to change notification settings - Fork 1
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
Sync Problem between "not immediately opened tabs" #2
Comments
That's a great point and I should highlight it more formally. It's not a distributed state machine, it merely records state transformations across tabs simultaneously. IOW it doesn't persist any state. When I used this in a personal project I used the initial state setting from a global context to get that. My particular use case also was only to specifically deal with tabs that were already open. If you think there's a clean way to handle it without forcing any localStorage usage or creating reducers, etc I'm all ears. |
@trevoro React.useEffect(initBroadcast , []); This action would basically post a message, saying a broadcast was initialized, and if:
I'm not sure what you meant by "creating reducers" but in this case only new actions would be added, what do you think? |
If you open two tabs and one of this tab changes the state before the other one be opened, the second tab it will still initialize with the
initValue
that doesn't correspond anymore to the real value and if the second tabs change the state it will override the changes made by the first one.Example:
Using the increment example in the README:
This is not very good when you state depends on the previous state
Possible Solution:
Maybe also save the state value on to use localStorage/sessionStorage and do?:
The text was updated successfully, but these errors were encountered: