Access Pinia Store globally #739
-
|
I just tried out pinia and so far I like it and would replace with it vuex in an app. In Vue I access sometimes getters or actions dynamically, via a string. Which I like. i. e.: A class, which checks if a getter ist true and returns it value So in a component, in setup, I can do: OR dispatch an action: I tried that with pinia, but stuck by not getting values: Is there a way, to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
You can call defineStore('a', () => {
const other = useOtherStore()
})or https://pinia.esm.dev/core-concepts/getters.html#accessing-other-stores-getters for options api |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for quick reply. Acutally I thought more of an auto import for all store files. But I just saw, that I used in vuex as well a function to do that. I do it now via But this works for me, so I guess I switch now to pinia :) |
Beta Was this translation helpful? Give feedback.
You can call
useOtherStore()inside of your store:or https://pinia.esm.dev/core-concepts/getters.html#accessing-other-stores-getters for options api