Chapter 4. State Management with Vuex
If you’ve read Chapter 2: Scaffolding Projects With Vue CLI 3, you’ll notice that “Vuex” was an option during your configuration setup. Vuex is a state management library created by the Core Team specifically for Vue.js. You can, of course, use other third party libraries like Redux for example. But the main advantages of using Vuex is 1) it’s simple and 2) it’s maintained by the Core Team.
State management can be puzzling at first, to say the least, but the best way to describe state is a single source of truth for your application’s data. The single source of truth is a large object, which stores any data that is global and that can change. Traditionally, it can be hard to traverse data across several “pages” in what is really one single index.html
file. With the introduction of state management into your application, maintaining global data is a breeze.
Imagine that you want to store...