Skip to content

Commit

Permalink
feat(url): call afterEach hooks after url is ensured (#2292)
Browse files Browse the repository at this point in the history
Closes #2079

This helps integrating with external scripts and makes more sense as the
navigation is finished.  However, onComplete callback passed to
`router.push` is now called before `afterEach` hooks. This shouldn't be
a problem as there's no guarantee provided anywhere in the docs about
this
  • Loading branch information
posva authored May 26, 2020
1 parent af75417 commit 1575a18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/history/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ export class History {
this.confirmTransition(
route,
() => {
const prev = this.current
this.updateRoute(route)
onComplete && onComplete(route)
this.ensureURL()
this.router.afterHooks.forEach(hook => {
hook && hook(route, prev)
})

// fire ready cbs once
if (!this.ready) {
Expand Down Expand Up @@ -214,12 +218,8 @@ export class History {
}

updateRoute (route: Route) {
const prev = this.current
this.current = route
this.cb && this.cb(route)
this.router.afterHooks.forEach(hook => {
hook && hook(route, prev)
})
}

setupListeners () {
Expand Down

0 comments on commit 1575a18

Please sign in to comment.