refactor(router): remove unused Pipeline

This commit is contained in:
Brian Ford 2015-08-24 14:39:54 -07:00
parent cac25fe003
commit d2458866c1
9 changed files with 18 additions and 70 deletions

View File

@ -75,7 +75,7 @@ function main() {
"}",
"});",
"var router = new RootRouter(registry, undefined, location, new Object());",
"var router = new RootRouter(registry, location, new Object());",
"$rootScope.$watch(function () { return $location.path(); }, function (path) {",
"if (router.lastNavigationAttempt !== path) {",
"router.navigateByUrl(path);",

View File

@ -14,7 +14,6 @@ export {LocationStrategy} from './src/router/location_strategy';
export {HashLocationStrategy} from './src/router/hash_location_strategy';
export {PathLocationStrategy} from './src/router/path_location_strategy';
export {Location, APP_BASE_HREF} from './src/router/location';
export {Pipeline} from './src/router/pipeline';
export * from './src/router/route_config_decorator';
export * from './src/router/route_definition';
export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/router/interfaces';
@ -30,7 +29,6 @@ import {Router, RootRouter} from './src/router/router';
import {RouterOutlet} from './src/router/router_outlet';
import {RouterLink} from './src/router/router_link';
import {RouteRegistry} from './src/router/route_registry';
import {Pipeline} from './src/router/pipeline';
import {Location} from './src/router/location';
import {APP_COMPONENT} from './src/core/application_tokens';
import {Binding} from './core';
@ -62,17 +60,13 @@ export const ROUTER_DIRECTIVES: any[] = CONST_EXPR([RouterOutlet, RouterLink]);
*/
export const ROUTER_BINDINGS: any[] = CONST_EXPR([
RouteRegistry,
Pipeline,
CONST_EXPR(new Binding(LocationStrategy, {toClass: PathLocationStrategy})),
Location,
CONST_EXPR(
new Binding(Router,
{
toFactory: routerFactory,
deps: CONST_EXPR([RouteRegistry, Pipeline, Location, APP_COMPONENT])
}))
CONST_EXPR(new Binding(
Router,
{toFactory: routerFactory, deps: CONST_EXPR([RouteRegistry, Location, APP_COMPONENT])}))
]);
function routerFactory(registry, pipeline, location, appRoot) {
return new RootRouter(registry, pipeline, location, appRoot);
function routerFactory(registry, location, appRoot) {
return new RootRouter(registry, location, appRoot);
}

View File

@ -1,30 +0,0 @@
import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
import {ListWrapper} from 'angular2/src/core/facade/collection';
import {Instruction} from './instruction';
import {Injectable} from 'angular2/src/core/di';
/**
* Responsible for performing each step of navigation.
* "Steps" are conceptually similar to "middleware"
*/
@Injectable()
export class Pipeline {
steps: Function[];
constructor() { this.steps = [instruction => instruction.router.activateOutlets(instruction)]; }
process(instruction: Instruction): Promise<any> {
var steps = this.steps, currentStep = 0;
function processOne(result: any = true): Promise<any> {
if (currentStep >= steps.length) {
return PromiseWrapper.resolve(result);
}
var step = steps[currentStep];
currentStep += 1;
return PromiseWrapper.resolve(step(instruction)).then(processOne);
}
return processOne();
}
}

View File

@ -15,7 +15,6 @@ import {
} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
import {RouteRegistry} from './route_registry';
import {Pipeline} from './pipeline';
import {ComponentInstruction, Instruction, stringifyInstruction} from './instruction';
import {RouterOutlet} from './router_outlet';
import {Location} from './location';
@ -57,8 +56,7 @@ export class Router {
private _subject: EventEmitter = new EventEmitter();
constructor(public registry: RouteRegistry, public _pipeline: Pipeline, public parent: Router,
public hostComponent: any) {}
constructor(public registry: RouteRegistry, public parent: Router, public hostComponent: any) {}
/**
@ -459,9 +457,8 @@ export class Router {
export class RootRouter extends Router {
_location: Location;
constructor(registry: RouteRegistry, pipeline: Pipeline, location: Location,
hostComponent: Type) {
super(registry, pipeline, null, hostComponent);
constructor(registry: RouteRegistry, location: Location, hostComponent: Type) {
super(registry, null, hostComponent);
this._location = location;
this._location.subscribe((change) =>
this.navigateByUrl(change['url'], isPresent(change['pop'])));
@ -485,7 +482,7 @@ export class RootRouter extends Router {
class ChildRouter extends Router {
constructor(parent: Router, hostComponent) {
super(parent.registry, parent._pipeline, parent, hostComponent);
super(parent.registry, parent, hostComponent);
this.parent = parent;
}

View File

@ -26,7 +26,6 @@ import {
} from 'angular2/src/core/facade/async';
import {RootRouter} from 'angular2/src/router/router';
import {Pipeline} from 'angular2/src/router/pipeline';
import {Router, RouterOutlet, RouterLink, RouteParams, ROUTE_DATA} from 'angular2/router';
import {
RouteConfig,
@ -63,14 +62,12 @@ export function main() {
var rtr;
beforeEachBindings(() => [
Pipeline,
RouteRegistry,
DirectiveResolver,
bind(Location).toClass(SpyLocation),
bind(Router)
.toFactory((registry, pipeline,
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
[RouteRegistry, Pipeline, Location])
.toFactory((registry, location) => { return new RootRouter(registry, location, MyComp); },
[RouteRegistry, Location])
]);
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {

View File

@ -20,7 +20,6 @@ import {CONST, NumberWrapper, isPresent, Json} from 'angular2/src/core/facade/la
import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
import {RootRouter} from 'angular2/src/router/router';
import {Pipeline} from 'angular2/src/router/pipeline';
import {Router, RouterOutlet, RouterLink, RouteParams, ROUTE_DATA} from 'angular2/router';
import {
RouteConfig,
@ -47,14 +46,12 @@ export function main() {
var rtr;
beforeEachBindings(() => [
Pipeline,
RouteRegistry,
DirectiveResolver,
bind(Location).toClass(SpyLocation),
bind(Router)
.toFactory((registry, pipeline,
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
[RouteRegistry, Pipeline, Location])
.toFactory((registry, location) => { return new RootRouter(registry, location, MyComp); },
[RouteRegistry, Location])
]);
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {

View File

@ -28,7 +28,6 @@ import {
Router,
RootRouter,
RouteRegistry,
Pipeline,
RouterLink,
RouterOutlet,
AsyncRoute,
@ -47,14 +46,12 @@ export function main() {
var router, location;
beforeEachBindings(() => [
Pipeline,
RouteRegistry,
DirectiveResolver,
bind(Location).toClass(SpyLocation),
bind(Router)
.toFactory((registry, pipeline,
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
[RouteRegistry, Pipeline, Location])
.toFactory((registry, location) => { return new RootRouter(registry, location, MyComp); },
[RouteRegistry, Location])
]);
beforeEach(inject([TestComponentBuilder, Router, Location], (tcBuilder, rtr, loc) => {

View File

@ -24,7 +24,6 @@ import {
Router,
RootRouter,
RouteRegistry,
Pipeline,
RouterLink,
RouterOutlet,
Route,

View File

@ -16,7 +16,6 @@ import {Promise, PromiseWrapper, ObservableWrapper} from 'angular2/src/core/faca
import {ListWrapper} from 'angular2/src/core/facade/collection';
import {Router, RootRouter} from 'angular2/src/router/router';
import {Pipeline} from 'angular2/src/router/pipeline';
import {SpyLocation} from 'angular2/src/mock/location_mock';
import {Location} from 'angular2/src/router/location';
import {stringifyInstruction} from 'angular2/src/router/instruction';
@ -32,14 +31,12 @@ export function main() {
var router, location;
beforeEachBindings(() => [
Pipeline,
RouteRegistry,
DirectiveResolver,
bind(Location).toClass(SpyLocation),
bind(Router)
.toFactory((registry, pipeline,
location) => { return new RootRouter(registry, pipeline, location, AppCmp); },
[RouteRegistry, Pipeline, Location])
.toFactory((registry, location) => { return new RootRouter(registry, location, AppCmp); },
[RouteRegistry, Location])
]);