onChange event triggers only after URL change, unable to abort route transition before URL change
Aadhisivam opened this issue · comments
Adhi commented
I would like to abort route transition based on certain conditions , so i utilised onChange event , but it triggers only after URL change.
I can abort transition in that event, but the url hash is changed which is irrelevant of the current route.
Is there any way to block this behaviour ?
Adhi commented
Edit : Cant Abort onChange event also
Tanjim Rahat commented
Adding a setTimeout worked for me
const onRoute = async ev => {
switch (ev.path) {
case '/login': {
if (auth == true) setTimeout(() => route('/home', true), 0)
}
}
}
Andriy Kornatskyy commented
the route
cannot be used as the active router is registered in ROUTERS
when it mounted (that means at the time you call route, the ROUTES
is empty list); so instead you can use ev.router.routeTo(...)
.