-
-
Notifications
You must be signed in to change notification settings - Fork 516
Open
Description
In the guides, it is suggested to use this.router.on
as a way to prevent a route transition:
However, this listener is never torn down, and will fire for all transitions in the app, regardless if they are from or to the current route.
export default class FormRoute extends Route {
@service router;
constructor() {
super(...arguments);
this.router.on('routeWillChange', (transition) => {
if (!transition.to.find(route => route.name === this.routeName) &&
!confirm('Are you sure you want to abandon progress?')) {
transition.abort();
}
});
}
};
I'd like to open a PR to include information about using router.off
here. Would that be helpful?
Metadata
Metadata
Assignees
Labels
No labels