In my template I can get the time from my store and that works fine. It updates whenever time changes. But when I map the getters from the state like this:
computed: {
...mapGetters({
week: "week",
year: "year",
time: "time",
}),
}
The values week and year never change. Why is that? What am I missing?
But doing this in the template works: $store.getters['week']
My State looks like this:
const state = {
time: moment(),
};
Actions:
const actions = {
changeTimeToNextWeek(context) {
context.commit("changeTimeToNextWeek");
},
changeTimeToPreviousWeek(context) {
context.commit("changeTimeToPreviousWeek");
},
};
Mutations:
const mutations = {
changeTimeToNextWeek(state) {
state.time = state.time.add(1, "week");
},
changeTimeToPreviousWeek(state) {
state.time = state.time.subtract(1, "week");
},
};
My getters look like this:
const getters = {
week: (state, getters) => {
return getters.time.isoWeek();
},
year: (state, getters) => {
return state.time.isoWeekYear();
},
time: (state, getters) => {
return state.time;
},
};