forked from angular/angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpipeline.js
More file actions
33 lines (28 loc) · 879 Bytes
/
pipeline.js
File metadata and controls
33 lines (28 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {List, ListWrapper} from 'angular2/src/facade/collection';
import {Instruction} from './instruction';
/**
* Responsible for performing each step of navigation.
* "Steps" are conceptually similar to "middleware"
*/
export class Pipeline {
steps:List<Function>;
constructor() {
this.steps = [
instruction => instruction.router.activateOutlets(instruction)
];
}
process(instruction:Instruction):Promise {
var steps = this.steps,
currentStep = 0;
function processOne(result:any = true):Promise {
if (currentStep >= steps.length) {
return PromiseWrapper.resolve(result);
}
var step = steps[currentStep];
currentStep += 1;
return PromiseWrapper.resolve(step(instruction)).then(processOne);
}
return processOne();
}
}