What will you get from this article?
This article attempts to teach you the popular store Vuex used in advanced, big and complex Vue.js ...
For further actions, you may consider blocking this person and/or reporting abuse
" ... or maybe you have a Single Page Application (SPA) that, of course, only has a single page. ..."
Heh? And how would you handle routes within a SPA without using vue-router? How should the user navigate? Maybe you should read again what a real SPA is :)
I think he's really serious about the "only has a single page." 😂
Tweaked that part a little. Thanks for pointing it out. I'm not an expert in Vue, so it really helps when someone tells me where I messed up 🙂.
Thanks for this article!
My (probably stupid) question is how would you use VueX to connect and manipulate an external data source?
Thanks again!
I'm hoping that your question was resolved, but just in case:
You would use
axios
in your store to go and get data from the API. For example:I know we can do this without Vuex as well. Is there a scenario where one would need Vuex for this? I can see how using an action would make it easy to post and get data from a data source. Are there any other scenarios?
I agree with you here. When using Vuex it is supposed to manage a state that passes across multiple components. Dropping Axios into the store to make API calls works but is it really necessary?
I am just getting into Vue, like you, so not sure if my opinion comes with any value. However, with my experience, I prefer to keep things in the "separation of concern". I have created an HTTP Service that serves as the base HTTP Model where I add headers, base routes, etc. and any customization to the route I override the base for the route in use.
Again this route seems like it has value with Users, but I think it should be more clear on the example. What if you're getting something unique to a single component? You're not going to want or need to drop that into the store. I am also very hesitant to mutate the state within the store. Seems like it goes against the principle of the store. The state is a snapshot in time when would you need to manipulate that?
No question is stupid. It's good to ask questions. You can connect and manipulate an external data source without Vuex as well.
Thanks for the great article! Really helped me understand how to access the store from components when I couldn't understand the docs.
Glad to hear the article was helpful 😄. Thanks for reading!
Thanks for the article! Good starting point.. I think it will solve a few things I hadn't wrapped my head around yet..
Thank you very much for the article!
Hello, Should I use vuex for creating a basic ecommerce project?
Thanks.