I have a nice mutation JS file like this.
export default {
UPDATE_DATA: (state, data, meta) => {
state.dataTable = data;
if (meta === undefined)
return;
state.activeDataRow = meta;
}, ...
}
It's being called by to different actions in the following ways.
context.commit("UPDATE_DATA", Map.table(payload.type, data));
context.commit("UPDATE_DATA", Map.table(payload.type, data), meta);
I've checked the meta being sent in the action and it's definitely not undefined. However, when I check the meta in the mutation, it is! Why? How do I kill this problem?
What vuex docs suggests is to send a payload in the second argument.
So you can call it like this with payload:
and your mutation will look like following:
There is an alternet way to calling mutations as well which is called Object-Style Commit. You can pass an object in commit, with type as mutation name, like following: