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

Proposal to Add Cross-Page State Synchronization to Pinia Plugin Persist #62

Open
yansenlei opened this issue Apr 23, 2023 · 0 comments

Comments

@yansenlei
Copy link

It is suggested to add a new feature to enable cross-page state synchronization in Pinia Plugin Persist. This feature can work with listening to the localStorage event, which will automatically synchronize the status of other web pages after one page updates the status. This will make it easier to handle most complex synchronization logic.

useEventListener(window, 'storage', (event) => {
    if (event.key === STORAGE_KEY) {
      const obj = JSON.parse(event.newValue || '{}')
      mykey.value = obj.mykey
    }
})
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