State Management with Vuex Chapter 21
countStore,
},
});
Our App.vue then changes slightly; instead of referencing the types object, we reference the
types specifically from this module:
import * as fromCount from './store/modules/count';
export default {
data() {
return {
amount: 0,
};
},
methods: {
increment() {
this.$store.dispatch(fromCount.INCREMENT, this.getAmount);
},
decrement() {
this.$store.dispatch(fromCount.DECREMENT, this.getAmount);
},
reset() {
this.$store.dispatch(fromCount.RESET);
},
},
computed: {
count() {
return this.$store.getters.count;
},
getAmount() {
return Number(this.amount) || 1;
},
},
};
We can then add more modules to our application by having the same files/structure as our
count example. This allows us to scale as our application continues to grow.