Skip to content

disallow route change until the 'resolve' will not be resolved #114 #116

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/route-segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,24 @@ mod.provider( '$routeSegment',
};

var resolvingSemaphoreChain = {};
var lastPromise = null;
var nextRequest;

// When a route changes, all interested parties should be notified about new segment chain
$rootScope.$on('$routeChangeSuccess', function(event, args) {
function $routeChangeSuccess(event, args) {

var route = args.$route || args.$$route;
if(route && route.segment) {

if (lastPromise) {
nextRequest = arguments;
return lastPromise.finally(function () {
lastPromise = null;
var nextRequestArguments = nextRequest;
nextRequest = null;
$routeChangeSuccess.apply(null, nextRequestArguments);
});
}

var segmentName = route.segment;
var segmentNameChain = segmentName.split(".");
var updates = [], lastUpdateIndex = -1;
Expand Down Expand Up @@ -500,7 +511,9 @@ mod.provider( '$routeSegment',
return defaultChildUpdatePromise;
});
}
});
}

$rootScope.$on('$routeChangeSuccess', $routeChangeSuccess);

function isDependenciesChanged(segment) {

Expand Down