Skip to content

Commit

Permalink
fix(navigation-command): add explicit interface for commands interest…
Browse files Browse the repository at this point in the history
…ed in child routers
  • Loading branch information
EisenbergEffect committed Mar 19, 2015
1 parent ae90ce2 commit 1e1c4d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
19 changes: 11 additions & 8 deletions src/activation.js
Expand Up @@ -158,9 +158,9 @@ function findActivatable(navigationContext, callbackName, list, router) {

if (viewPortPlan.childNavigationContext) {
findActivatable(
viewPortPlan.childNavigationContext,
callbackName,
list,
viewPortPlan.childNavigationContext,
callbackName,
list,
controller.router || router
);
}
Expand All @@ -170,22 +170,25 @@ function findActivatable(navigationContext, callbackName, list, router) {
}

function shouldContinue(output, router) {
if (output instanceof Error) {
if(output instanceof Error) {
return false;
}

if(isNavigationCommand(output)){
output.router = router;
if(typeof output.setRouter === 'function') {
output.setRouter(router);
}

return !!output.shouldContinueProcessing;
}

if (typeof output == 'string') {
if(typeof output === 'string') {
return affirmations.indexOf(value.toLowerCase()) !== -1;
}

if (typeof output == 'undefined') {
if(typeof output === 'undefined') {
return true;
}

return output;
}
}
12 changes: 11 additions & 1 deletion src/navigation-commands.js
Expand Up @@ -21,6 +21,16 @@ export class Redirect{
this.shouldContinueProcessing = false;
}

/**
* Called by the activation system to set the child router.
*
* @method setRouter
* @param {Router} router
*/
setRouter(router){
this.router = router;
}

/**
* Called by the navigation pipeline to navigate.
*
Expand All @@ -30,4 +40,4 @@ export class Redirect{
navigate(appRouter){
(this.router || appRouter).navigate(this.url, { trigger: true, replace: true });
}
}
}

0 comments on commit 1e1c4d3

Please sign in to comment.