DEV Community

Discussion on: Explain Stores (Vuex) Like I'm Five

Collapse
 
isaacdlyman profile image
Isaac Lyman

Your English is excellent.

Assuming the Vuex store and the global service are both local (no HTTP requests or anything), the differences are:

  • Vue knows about the Vuex store, so it can do change tracking on it. If something changes in the Vuex store, the Vue app can update computed properties and watchers and re-render the DOM where necessary. If something changes in a global service, Vue won't know about it.
  • A global service is mutable, so it's harder to track changes to it as the application runs. A Vuex store is immutable--every time you change the state, a new object is created to hold the data. This means you can find out what changed between one state and the next by comparing the objects.
  • Vuex stores have some extra functionality, like NPM packages and plugins that can help you organize your state or even persist it to LocalStorage automatically.
Thread Thread
 
gerchog profile image
Germán González

Excellent answer. Very clear for me!

Thank you very very much!