Skip to content

Add a way to catch a route cancel #2011

Closed
@ghost

Description

There are occasions where a route should be handled everytime it’s considered. For example, I’ve seen it suggested that VueRouter could be used to show a loading indicator by doing the following:

router.beforeEach((to, from, next) => {
    LoadIndicator.show();
    next();
});
router.afterEach((to, from) => {
    LoadIndicator.hide();
});

A route can be cancelled in a component’s beforeRouteEnter method with next(false), but AfterEach won’t fire since the route never actually loaded and the loading indicatior is stuck.

Something like that would be great:

router.cancel((to, from) => {
    LoadIndicator.hide();
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions