davestewart / vuex-pathify

Vue / Vuex plugin providing a unified path syntax to Vuex stores
https://davestewart.github.io/vuex-pathify
MIT License
1.37k stars 57 forks source link

Use vuex-pathify in separate tyescript module #109

Closed haexhub closed 4 years ago

haexhub commented 4 years ago

Hi,

I would like to know, if its possible to use vuex-pathify outside of a normal vue component.

I organize (some of) my code in separate typescript files, which later get imported in vue components for use. And I would like to use vuex-pathify / vuex in this normal typescript files. Is that possible? If I could import the context of the vue app to the typescript file, I could access everything, but I'm not sure how to do this nicely. Does anyone has an idea / experience with this?

davestewart commented 4 years ago

Hey there.

Sorry... I don't understand the question!

Can you post some code, either here, or on Code Sandbox?

If you need to demo code, fork and edit the Pathify simple demo...

...then paste a link to your edited demo.

haexhub commented 4 years ago

Hi Dave,

thank you for your time and reply. I made a demo repo where I made it work. My goal is, to keep the state files as close as possible to the components, they belong to. You can see this approach in the component components/demo. Maybe you have some other ideas. :)

davestewart commented 4 years ago

Hey @haexhub,

Nice solution!

I generally build my applications in modules these days, and as you say, stores (and routes, and services, etc) live together, and I glue the families of pieces together when the application starts.

Nuxt is a of course a bit different as its folder system AKAIK is static, so I really like your approach.

FWIW I generally put state, mutations, actions etc in one file:

I'm going to mark this as closed as a) you seem to have found a solution and b) it's not really a pathify issue.

Feel free to keep commenting or reopen if you think it appropriate.

Cheers, Dave