You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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. Note you can attach properties to a route location .meta property
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Im facing a need to have global
onBeforeRouteLeave
and wondering if there's a workaround with current api.the use case is:
I've tried to use
router.beforeEach
guardbut it seems that it also cancel queries from the route B somehow.
when using
onBeforeRouteLeave
on route A component it looks like it's working properly.I'm trying to find a way to hook globally to the same lifecycle step as
onBeforeRouteLeave
Beta Was this translation helpful? Give feedback.
All reactions