Machine Name: Bender
Machine ID: 2
State: Operational
Machine Name: Farnsworth
Machine ID: 1
State: Retire
Machine Name: Fry
Machine ID: 3
State: Operational
Restock Request
Check Status
Fulfill request
Restock request
Deny request
Restock
Check Machine State
Fetch From Inventory
wait
success
fail
success
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
getters: {},
state: {
stock: 30,
},
mutations: {},
actions: {
fetchFromInventory({ commit }) {
API_CALLING()
.then(result => {
commit('restock', result.json())
})
},
checkMachineCondition(machine) {
return new Promise((resolve, reject) => {
setTimeout(() => {
commit('someMutation')
resolve()
}, 1000)
})
}
}
},
mutations: {
restock(state, payload) {
state.stock = payload
}
}
})
In the `fetchFromInventory` action, dispatch a call to check the machine state action
[step-0]
https://github.com/shortdiv/vuex-compose-actions