global onBeforeRouteLeave #2350
-
Im facing a need to have global
I've tried to use
but it seems that it also cancel queries from the route B somehow. when using
I'm trying to find a way to hook globally to the same lifecycle step as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The global equivalent is a |
Beta Was this translation helpful? Give feedback.
The global equivalent is a
router.beforeResolve()
(similar torouter.beforeEach()
), but you need to write the "leaving" condition (aka what does leaving mean) yourself by manually comparing the two locations and more probably, theirmatched
properties. It's up to you to decide if leaving means thatto.matched
andfrom.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. …