Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vuex-pathify in separate tyescript module #109

Closed
haexhub opened this issue Aug 7, 2020 · 3 comments
Closed

Use vuex-pathify in separate tyescript module #109

haexhub opened this issue Aug 7, 2020 · 3 comments

Comments

@haexhub
Copy link

haexhub commented Aug 7, 2020

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
Copy link
Owner

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
Copy link
Author

haexhub commented Aug 8, 2020

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
Copy link
Owner

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:

  • it's 4 x less files
  • it makes it easier to see all the code together
  • it makes importing and modules easier

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants