I'm having trouble getting my commit to work on a store.
I am calling the mutation via an action, which seems to work fine.
export const location = {
state: {
x: 0,
y: 0,
z: 0,
extent: [],
epsg: 'EPSG:3857'
},
mutations: {
setLocation(state, payload) {
// mutate state
console.log("Commit");
state.x = payload.x;
state.y = payload.y;
console.dir(state); //this does return the mutated state.
}
},
actions: {
setLocation(context, payload) {
console.dir(payload);
context.commit('setLocation', payload);
}
},
getters: {
mapLocation(state) {
return state
}
}
}
The action is imported into my component:
methods: {
...mapActions(['setLocation']),
and then called:
var location = {
x: data[0],
y: data[1]
}
this.setLocation(location);
This all appears to work, but when I check out Vue Developer Tools, the Vuex Base state remains unchanged and I have an active mutation (setLocation). I can click 'Commit All' to commit the mutation which works.
In my component I am using a watcher on the getter mapLocation which fires when I click Commit All.
How can I force it to commit to the store?
Thanks