Skip to content

Commit

Permalink
feat(activation): call can/Deactivate with navigationInstructions
Browse files Browse the repository at this point in the history
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 3d3c444
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/activation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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

Expand All @@ -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);
Expand Down

0 comments on commit 3d3c444

Please sign in to comment.