This is where all the in-memory data of your app is stored. Mutations fetch data from APIs, databases etc. and keep it here.
You can have only a single store in the app. If you want to divide the store, you can create more models and add their instances to this class. For example:
Reason for using a single store:
- Single source of truth
- Easily persist store by serializing it
- Jump between different instances of store like Redux time travel
You can attach store to your app like this:
This is essentially a global variable which means you should be a little bit careful while writing tests. You should not keep reference to store instance. Access should be restricted only though
VxState.store getter, like below, to avoid some common mistakes.