greenpress / vuex-composition-helpers

A util package to use Vuex with Composition API easily.
https://www.npmjs.com/package/vuex-composition-helpers
MIT License
288 stars 32 forks source link

[Feature request] A composition hook simply to get this.$store #40

Closed lyle45 closed 2 years ago

lyle45 commented 3 years ago

Is there a way to add a useStore hook to get the injected store attached to vue root?

I know that same can be accessed via ctx.root.$store, but if you've dabbled with the composition enough you know sometimes hooks get far away from Vue instance (a hook calling a hook calling a hook) and we want to avoid param soup only to call store under the 5th hook called

For a different reason we don't want to import store directly as we're sharing modules between apps with lerna, so store instance can be different with each use

not sure if it's possible for vuex v3

davidmeirlevy commented 3 years ago

Hi!

Thanks for this idea. We actually have this function internally inside the library, so we just need to expose it.

Look for src/utils.ts, at the function "getStoreFromInstance"