Skip to content

Replace veux $store with $pinia #1958

Discussion options

You must be logged in to vote

You already have $pinia available, which gives you access to all instantiated stores' state:

this.$pinia.state.value

If you want access to the stores, you will need to collect them in a plugin and add them to global properties:

const stores = {}
pinia.use(({ store }) => {
  stores[store.$id] = store
})
app.config.globalProperties.$stores = stores

But I recommend you to avoid this because it cannot be made type safe and stays in an "vuex way of thinking" instead of embracing the new defaults that enable better code splitting and dynamic registration by default

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants