I have a vuex store, like following:
import spreeApi from \'../../gateways/spree-api\'
// initial state
const state = {
products: [],
categories: []
}
// mu
I prefer to call mutations.SET_CATEGORIES(state)
instead of:
- calling 2 different commits from an artificial action
- or doing commit()
inside a mutation as it makes unit testing more difficult.
const mutations = {
SET_PRODUCTS: (state, response) => {
state.products = response.data.products
mutations.SET_CATEGORIES(state)
},
SET_CATEGORIES: (state) => {
state.categories = state.products.map(product => product.category)
}
}
My opinion is that you don't need to see SET_CATEGORIES
in the VueToolbox. The time travel should work anyways. Please, correct me if I'm wrong.