Skip to content

global onBeforeRouteLeave #2350

Closed Answered by posva
dvh91 asked this question in Help and Questions
Discussion options

You must be logged in to vote

The global equivalent is a router.beforeResolve() (similar to router.beforeEach()), but you need to write the "leaving" condition (aka what does leaving mean) yourself by manually comparing the two locations and more probably, their matched properties. It's up to you to decide if leaving means that to.matched and from.matched have no common route records or something else.
That being said, if you want to cancel a query, you will probably have to provide another filter than just fetching. That will again be up to you, depending on the keys you have and you will likely need to implement some mechanism to attach current fetching queries to the current route, maybe with a watcher or similar. …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by posva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants