В действии Vuex мы имеем следующую реализацию:
async actionA({ commit, dispatch }) {
const data = this.$axios.$get(`/apiUrl`)
await Promise.all([
dispatch('actionB', { data: data }),
dispatch('actionOthers'),
]).then(() => {
commit('mutationA', data)
})
}
async actionB({ commit, dispatch }, { data }) {
await this.$axios.$get('/apiUrl', { params: data }).then(res => {
if (res.length === 0) {
dispatch('actionC', { data: data })
}
commit('mutationB', res)
})
}
async actionC({ commit, dispatch }, { data }) {
await this.$axios.$get('/anotherUrl', { params: data }).then(res => {
commit('mutationC', res)
})
}
Отправка actionB
из actionA
и отправка actionC
из actionB
в зависимости от результата actionB
.
Однако actionA
будет разрешено до завершения actionC
.
Как мне справиться с такими случаями?