2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-24 12:20:33 +03:00

circumvent need to call refresh() after async actions

This commit is contained in:
Declan de Wet
2016-11-10 22:24:38 +02:00
parent c20206d859
commit 1c9f6d08f3
5 changed files with 54 additions and 42 deletions
+4 -9
View File
@@ -63,15 +63,10 @@ export default new Vuex.Store({
actions: {
getPost ({ commit }, payload) {
commit('loadingState', { isLoading: true })
// we have to return a promise from this action so we know
// when it is finished
return new Promise((resolve) => {
setTimeout(() => {
commit('getPost', payload)
resolve()
}, 2000)
})
.then(() => commit('loadingState', { isLoading: false }))
setTimeout(() => {
commit('getPost', payload)
commit('loadingState', { isLoading: false })
}, 2000)
}
}
})