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

Missing handling of changes performed on other changes #83

Open
vhermecz opened this issue Nov 22, 2024 · 0 comments
Open

Missing handling of changes performed on other changes #83

vhermecz opened this issue Nov 22, 2024 · 0 comments

Comments

@vhermecz
Copy link

vhermecz commented Nov 22, 2024

Adding something like:

      // NOTE: Code below is not production grade, just pseudo-code
      // Sync across tabs
      const handleStorageChange = (event: StorageEvent) => {
        if (event.key === key && event.newValue != null) {
          setSelf(JSON.parse(event.newValue)[node.key]);
        }
      };
      window.addEventListener('storage', handleStorageChange);

      return () => {
        window.removeEventListener('storage', handleStorageChange);
      };

would ensure that changes made to node.key in another browser tab would be picked up.
As localStorage supports this behavior, I believe it is fair to expect that recoil-persist would also handle it. Thx!

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

1 participant