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
}
}
})