Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

Commit

Permalink
fix: Fix issue where asyncData wouldn't be reloaded if the router vie…
Browse files Browse the repository at this point in the history
…w component is the same on route change.
  • Loading branch information
Kaptard committed Jul 12, 2018
1 parent 5ae5a95 commit daeb45b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
9 changes: 2 additions & 7 deletions vue/app-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ router.onReady(() => {
// async components are resolved.
router.beforeResolve(async (to, from, next) => {
const matched = router.getMatchedComponents(to)
const prevMatched = router.getMatchedComponents(from)
let diffed = false
const activated = matched.filter((c, i) => {
return diffed || (diffed = (prevMatched[i] !== c))
})

// Register dyanmic store modules on route change (not direct load!)
registerStoreModules(root, store)
activated.map(component => registerStoreModules(component, store, true))
matched.map(component => registerStoreModules(component, store, true))

// Call asyncData
await Promise.all(activated.map(c => callAsyncRecursive(c, store, router, to, progress)))
await Promise.all(matched.map(c => callAsyncRecursive(c, store, router, to, progress)))

// End loading bar
progress.finish()
Expand Down
1 change: 1 addition & 0 deletions vue/ssr/callAsyncRecursive.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const callAsyncRecursive = async (parent, store, router, route, progress) => {
if (parent.asyncData) {
if (!progressStarted && progress) {
progress.start()
progressStarted = true
}
parent.$router = router
parent.$store = store
Expand Down

0 comments on commit daeb45b

Please sign in to comment.