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

Feature request: Listen for the storage event to keep localStorage synced across multiple tabs #1

Closed
Greenheart opened this issue Mar 19, 2023 · 2 comments

Comments

@Greenheart
Copy link

Nice library! Especially the combination of using zod to parse data, and automatically initialising the store. (I've previously manually initialised the store on each page with this implementation which works but is a worse DX).

One feature that could be a nice addition to this library is to listen for the storage event on the window, and always use the latest value no matter which tab has been used. This event tells us which localStorage key that was changed, making it possible to only update when the relevant key has changed in another tab.

To keep the core library clean, this feature should likely be opt-in when creating the store.

@efstajas
Copy link
Owner

This is a great suggestion, will add this soon, thanks.

@efstajas
Copy link
Owner

@Greenheart This is added in v0.2.0 :)

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

No branches or pull requests

2 participants