Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant