Handling state in single-page apps can be a tricky process, especially as an application gets larger and more complex. In this tutorial, you'll discover how Vuex, Vue's state management solution, simplifies state management.
In single-page applications, the concept of state relates to any piece of data that can change. An example of state could be the details of a logged-in user, or data fetched from an API.
Handling state in single-page apps can be a tricky process. As an application gets larger and more complex, you start to encounter situations where a given piece of state needs to be used in multiple components, or you find yourself passing state through components that don’t need it, just to get it to where it needs to be. This is also known as “prop drilling”, and can lead to some unwieldy code.
Vuex is the official state management solution for Vue. It works by having a central store for shared state, and providing methods to allow any component in your application to access that state. In essence, Vuex ensures your views remain consistent with your application data, regardless of which function triggers a change to your application data.
In this book, I’ll offer you a high-level overview of Vuex and demonstrate how to implement it into a simple app.
5
Unlimited access to this title and 600+ others in our library
New titles added frequently
Cancel anytime