vue-web-component-wrapper icon indicating copy to clipboard operation
vue-web-component-wrapper copied to clipboard

Share a pinia store between instances of a web component

Open EitanGoldfrad opened this issue 1 year ago • 4 comments

Hi @EranGrin

Is there a way to share a synced pinia store between different instances of the same component?

For example, if I have a with a store "buttonStore" and state "on" or "off"

When setting the state of one store I would like all of the instances to share the same state.

Thanks!

EitanGoldfrad avatar Dec 08 '24 09:12 EitanGoldfrad

This is indeed an interesting use case, I'll try to look into it in the coming days.

EranGrin avatar Dec 08 '24 16:12 EranGrin

The question is actually if pinia can support store between multiple vue instances, if you can find a way to do it, I would be eager to help to adapt this to the web component. Otherwise, the issue isn't in the scope of this plugin.

EranGrin avatar Dec 17 '24 08:12 EranGrin

Hi Eran,

Looks like it's possible here (I didn't test it): https://gist.github.com/posva/28604e178deb5d5c9ab6cea86232053b

My current workaround is to use localStorage with the pinia persist plugin to communicate between the web components, but it's not the best solution.

Thanks

EitanGoldfrad avatar Dec 17 '24 08:12 EitanGoldfrad

Looks promising, I would try to dive into it in the coming days

EranGrin avatar Dec 17 '24 09:12 EranGrin