11. Working with Vuex – Organizing Larger Stores
Activity 11.01: Simplifying a Vuex Store
Solution:
Perform the following steps to complete the activity.
Note
To access the initial code file for this activity, visit https://packt.live/3kaqBHH.
- Begin by creating a new file,
src/store/state.js
, that will store the state values for everything but thecat
object:export default { name:'Lindy', job:'tank', favoriteColor:'blue', favoriteAnimal:'cat' }
- Make a new file,
src/store/getters.js
, and move the getter fordesiredPet
into it:export default { desiredPet(state) { return state.favoriteColor + ' ' + state.favoriteAnimal; } }
- Next, make
src/store/mutations.js
and copy over themutations
not related to the cat name...