mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-22 23:50:34 +03:00
circumvent need to call refresh() after async actions
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -18,11 +18,7 @@
|
||||
name: 'post',
|
||||
beforeMount () {
|
||||
const { slug } = this.$route.params
|
||||
// since fetching a post is asynchronous,
|
||||
// we need to call `this.$meta().refresh()`
|
||||
// to update the meta info
|
||||
this.$store.dispatch('getPost', { slug })
|
||||
.then(() => this.$meta().refresh())
|
||||
},
|
||||
computed: mapGetters([
|
||||
'isLoading',
|
||||
|
||||
Reference in New Issue
Block a user