Splitting The Store Into Modules
Explore how to divide your Vuex store into modules to manage complex state more effectively. Understand namespaced states, getters, mutations, and actions, and learn best practices for keeping your store modular and maintainable.
We'll cover the following...
The larger an app gets, the larger the state machine will be. Over time, we add features to our app, let it communicate with more endpoints, and perform more complex tasks. We tend to split code into units related to either features or the kind of code, such as controllers or services. We can also split our Vuex store into different modules.
Splitting the store helps us separate concerns. For example, if we have dozens of getters and fields, they might not be related to each other and serve entirely different purposes. Usually, we can anticipate how large a store will get and what kind of modules we will have. It is, therefore, recommended to split the store early on.
How to define submodules
A Vuex store can ...