Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transitions which are aborted by an onBefore hook should not supersede other pending transitions #41

Closed
00dani opened this issue Feb 17, 2017 · 0 comments
Milestone

Comments

@00dani
Copy link

00dani commented Feb 17, 2017

Currently a transition will always supersede any transitions that started before it - unfortunately, this includes transitions which never actually started themselves, due to being interrupted by an onBefore hook. For example, I wrote the following simple onBefore hook to prevent several clicks on the same ui-sref from "stacking up":

    mod.config(function($transitionsProvider) {
        let prevTarget = undefined;
        $transitionsProvider.onBefore({}, function(trans) {
            const target = trans.targetState().toString();
            if (prevTarget && target === prevTarget) return false;
            prevTarget = target;
        }, {priority: 9999});
    });

If you click the ui-sref several times, only the first transition will attempt to fetch its resolve data (as desired), with all later transitions immediately being aborted. However, once all resolve data have been retrieved, the first transition is also cancelled since other transitions were attempted.

Since onBefore is meant to be invoked before the transition even begins, it should be able to intercept and throw away unwanted transitions entirely, without having them interrupt other operations.

@christopherthielen christopherthielen added this to the 5.0.0 milestone Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants