Skip to content
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

Adds option to disable syncing across tabs #226

Merged
merged 1 commit into from
Dec 20, 2023
Merged

Conversation

joshnuss
Copy link
Owner

A new config option to disable syncing across tabs.

Usage

const store = persisted(key, initial, { syncTabs: true })

Default is true, to maintain backwards compatibility.

@bertmad3400
Copy link
Contributor

When I first looked at this PR, it seemed strange and unnecessary to me, but after thinking the use-cases through, it actually makes a lot of sense. Would be awesome to have in the lib

@joshnuss
Copy link
Owner Author

Thanks for the feedback @bertmad3400,

I think it can lead to one tab overwriting another's local storage (race conditions), but in some cases, that's OK.

For example, when storing preferences in local storage, it could be weird if changes in one tab adjusted the other tab.
It's fine if the last one to update wins.

@joshnuss joshnuss merged commit ac50568 into master Dec 20, 2023
4 checks passed
@joshnuss joshnuss deleted the optional-sync branch December 20, 2023 11:27
Copy link

🎉 This PR is included in version 0.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants