Permalink
Browse files

feat(activation): call can/Deactivate with navigationInstructions

This enables the consumer to inspect the navigation instructions and make a decision on whether or not a route can be deactivated based on the incoming navigation instructions.

Closes #493
  • Loading branch information...
davismj committed Jul 25, 2017
1 parent 5600ca9 commit 3d3c444c6ad0aee43c828fd0a836f7d67f2f2ddc
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/activation.js
View
@@ -3,7 +3,7 @@ import {isNavigationCommand} from './navigation-commands';
export class CanDeactivatePreviousStep {
run(navigationInstruction: NavigationInstruction, next: Function) {
return processDeactivatable(navigationInstruction.plan, 'canDeactivate', next);
return processDeactivatable(navigationInstruction, 'canDeactivate', next);
}
}
@@ -15,7 +15,7 @@ export class CanActivateNextStep {
export class DeactivatePreviousStep {
run(navigationInstruction: NavigationInstruction, next: Function) {
return processDeactivatable(navigationInstruction.plan, 'deactivate', next, true);
return processDeactivatable(navigationInstruction, 'deactivate', next, true);
}
}
@@ -25,7 +25,8 @@ export class ActivateNextStep {
}
}
function processDeactivatable(plan, callbackName, next, ignoreResult) {
function processDeactivatable(navigationInstruction: NavigationInstruction, callbackName: string, next: Funcion, ignoreResult: boolean) {
const plan = navigationInstruction.plan;
let infos = findDeactivatable(plan, callbackName);
let i = infos.length; //query from inside out
@@ -41,7 +42,7 @@ function processDeactivatable(plan, callbackName, next, ignoreResult) {
if (i--) {
try {
let viewModel = infos[i];
let result = viewModel[callbackName]();
let result = viewModel[callbackName](navigationInstruction);
return processPotential(result, inspect, next.cancel);
} catch (error) {
return next.cancel(error);

0 comments on commit 3d3c444

Please sign in to comment.