refactor(router): remove unused Pipeline
This commit is contained in:
parent
cac25fe003
commit
d2458866c1
|
@ -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) {",
|
"$rootScope.$watch(function () { return $location.path(); }, function (path) {",
|
||||||
"if (router.lastNavigationAttempt !== path) {",
|
"if (router.lastNavigationAttempt !== path) {",
|
||||||
"router.navigateByUrl(path);",
|
"router.navigateByUrl(path);",
|
||||||
|
|
|
@ -14,7 +14,6 @@ export {LocationStrategy} from './src/router/location_strategy';
|
||||||
export {HashLocationStrategy} from './src/router/hash_location_strategy';
|
export {HashLocationStrategy} from './src/router/hash_location_strategy';
|
||||||
export {PathLocationStrategy} from './src/router/path_location_strategy';
|
export {PathLocationStrategy} from './src/router/path_location_strategy';
|
||||||
export {Location, APP_BASE_HREF} from './src/router/location';
|
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_config_decorator';
|
||||||
export * from './src/router/route_definition';
|
export * from './src/router/route_definition';
|
||||||
export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/router/interfaces';
|
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 {RouterOutlet} from './src/router/router_outlet';
|
||||||
import {RouterLink} from './src/router/router_link';
|
import {RouterLink} from './src/router/router_link';
|
||||||
import {RouteRegistry} from './src/router/route_registry';
|
import {RouteRegistry} from './src/router/route_registry';
|
||||||
import {Pipeline} from './src/router/pipeline';
|
|
||||||
import {Location} from './src/router/location';
|
import {Location} from './src/router/location';
|
||||||
import {APP_COMPONENT} from './src/core/application_tokens';
|
import {APP_COMPONENT} from './src/core/application_tokens';
|
||||||
import {Binding} from './core';
|
import {Binding} from './core';
|
||||||
|
@ -62,17 +60,13 @@ export const ROUTER_DIRECTIVES: any[] = CONST_EXPR([RouterOutlet, RouterLink]);
|
||||||
*/
|
*/
|
||||||
export const ROUTER_BINDINGS: any[] = CONST_EXPR([
|
export const ROUTER_BINDINGS: any[] = CONST_EXPR([
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
Pipeline,
|
|
||||||
CONST_EXPR(new Binding(LocationStrategy, {toClass: PathLocationStrategy})),
|
CONST_EXPR(new Binding(LocationStrategy, {toClass: PathLocationStrategy})),
|
||||||
Location,
|
Location,
|
||||||
CONST_EXPR(
|
CONST_EXPR(new Binding(
|
||||||
new Binding(Router,
|
Router,
|
||||||
{
|
{toFactory: routerFactory, deps: CONST_EXPR([RouteRegistry, Location, APP_COMPONENT])}))
|
||||||
toFactory: routerFactory,
|
|
||||||
deps: CONST_EXPR([RouteRegistry, Pipeline, Location, APP_COMPONENT])
|
|
||||||
}))
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
function routerFactory(registry, pipeline, location, appRoot) {
|
function routerFactory(registry, location, appRoot) {
|
||||||
return new RootRouter(registry, pipeline, location, appRoot);
|
return new RootRouter(registry, location, appRoot);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ import {
|
||||||
} from 'angular2/src/core/facade/lang';
|
} from 'angular2/src/core/facade/lang';
|
||||||
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
|
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
|
||||||
import {RouteRegistry} from './route_registry';
|
import {RouteRegistry} from './route_registry';
|
||||||
import {Pipeline} from './pipeline';
|
|
||||||
import {ComponentInstruction, Instruction, stringifyInstruction} from './instruction';
|
import {ComponentInstruction, Instruction, stringifyInstruction} from './instruction';
|
||||||
import {RouterOutlet} from './router_outlet';
|
import {RouterOutlet} from './router_outlet';
|
||||||
import {Location} from './location';
|
import {Location} from './location';
|
||||||
|
@ -57,8 +56,7 @@ export class Router {
|
||||||
private _subject: EventEmitter = new EventEmitter();
|
private _subject: EventEmitter = new EventEmitter();
|
||||||
|
|
||||||
|
|
||||||
constructor(public registry: RouteRegistry, public _pipeline: Pipeline, public parent: Router,
|
constructor(public registry: RouteRegistry, public parent: Router, public hostComponent: any) {}
|
||||||
public hostComponent: any) {}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -459,9 +457,8 @@ export class Router {
|
||||||
export class RootRouter extends Router {
|
export class RootRouter extends Router {
|
||||||
_location: Location;
|
_location: Location;
|
||||||
|
|
||||||
constructor(registry: RouteRegistry, pipeline: Pipeline, location: Location,
|
constructor(registry: RouteRegistry, location: Location, hostComponent: Type) {
|
||||||
hostComponent: Type) {
|
super(registry, null, hostComponent);
|
||||||
super(registry, pipeline, null, hostComponent);
|
|
||||||
this._location = location;
|
this._location = location;
|
||||||
this._location.subscribe((change) =>
|
this._location.subscribe((change) =>
|
||||||
this.navigateByUrl(change['url'], isPresent(change['pop'])));
|
this.navigateByUrl(change['url'], isPresent(change['pop'])));
|
||||||
|
@ -485,7 +482,7 @@ export class RootRouter extends Router {
|
||||||
|
|
||||||
class ChildRouter extends Router {
|
class ChildRouter extends Router {
|
||||||
constructor(parent: Router, hostComponent) {
|
constructor(parent: Router, hostComponent) {
|
||||||
super(parent.registry, parent._pipeline, parent, hostComponent);
|
super(parent.registry, parent, hostComponent);
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ import {
|
||||||
} from 'angular2/src/core/facade/async';
|
} from 'angular2/src/core/facade/async';
|
||||||
|
|
||||||
import {RootRouter} from 'angular2/src/router/router';
|
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 {Router, RouterOutlet, RouterLink, RouteParams, ROUTE_DATA} from 'angular2/router';
|
||||||
import {
|
import {
|
||||||
RouteConfig,
|
RouteConfig,
|
||||||
|
@ -63,14 +62,12 @@ export function main() {
|
||||||
var rtr;
|
var rtr;
|
||||||
|
|
||||||
beforeEachBindings(() => [
|
beforeEachBindings(() => [
|
||||||
Pipeline,
|
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
DirectiveResolver,
|
DirectiveResolver,
|
||||||
bind(Location).toClass(SpyLocation),
|
bind(Location).toClass(SpyLocation),
|
||||||
bind(Router)
|
bind(Router)
|
||||||
.toFactory((registry, pipeline,
|
.toFactory((registry, location) => { return new RootRouter(registry, location, MyComp); },
|
||||||
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
|
[RouteRegistry, Location])
|
||||||
[RouteRegistry, Pipeline, Location])
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
|
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
|
||||||
|
|
|
@ -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 {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
|
||||||
|
|
||||||
import {RootRouter} from 'angular2/src/router/router';
|
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 {Router, RouterOutlet, RouterLink, RouteParams, ROUTE_DATA} from 'angular2/router';
|
||||||
import {
|
import {
|
||||||
RouteConfig,
|
RouteConfig,
|
||||||
|
@ -47,14 +46,12 @@ export function main() {
|
||||||
var rtr;
|
var rtr;
|
||||||
|
|
||||||
beforeEachBindings(() => [
|
beforeEachBindings(() => [
|
||||||
Pipeline,
|
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
DirectiveResolver,
|
DirectiveResolver,
|
||||||
bind(Location).toClass(SpyLocation),
|
bind(Location).toClass(SpyLocation),
|
||||||
bind(Router)
|
bind(Router)
|
||||||
.toFactory((registry, pipeline,
|
.toFactory((registry, location) => { return new RootRouter(registry, location, MyComp); },
|
||||||
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
|
[RouteRegistry, Location])
|
||||||
[RouteRegistry, Pipeline, Location])
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
|
beforeEach(inject([TestComponentBuilder, Router], (tcBuilder, router) => {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import {
|
||||||
Router,
|
Router,
|
||||||
RootRouter,
|
RootRouter,
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
Pipeline,
|
|
||||||
RouterLink,
|
RouterLink,
|
||||||
RouterOutlet,
|
RouterOutlet,
|
||||||
AsyncRoute,
|
AsyncRoute,
|
||||||
|
@ -47,14 +46,12 @@ export function main() {
|
||||||
var router, location;
|
var router, location;
|
||||||
|
|
||||||
beforeEachBindings(() => [
|
beforeEachBindings(() => [
|
||||||
Pipeline,
|
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
DirectiveResolver,
|
DirectiveResolver,
|
||||||
bind(Location).toClass(SpyLocation),
|
bind(Location).toClass(SpyLocation),
|
||||||
bind(Router)
|
bind(Router)
|
||||||
.toFactory((registry, pipeline,
|
.toFactory((registry, location) => { return new RootRouter(registry, location, MyComp); },
|
||||||
location) => { return new RootRouter(registry, pipeline, location, MyComp); },
|
[RouteRegistry, Location])
|
||||||
[RouteRegistry, Pipeline, Location])
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
beforeEach(inject([TestComponentBuilder, Router, Location], (tcBuilder, rtr, loc) => {
|
beforeEach(inject([TestComponentBuilder, Router, Location], (tcBuilder, rtr, loc) => {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import {
|
||||||
Router,
|
Router,
|
||||||
RootRouter,
|
RootRouter,
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
Pipeline,
|
|
||||||
RouterLink,
|
RouterLink,
|
||||||
RouterOutlet,
|
RouterOutlet,
|
||||||
Route,
|
Route,
|
||||||
|
|
|
@ -16,7 +16,6 @@ import {Promise, PromiseWrapper, ObservableWrapper} from 'angular2/src/core/faca
|
||||||
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
import {ListWrapper} from 'angular2/src/core/facade/collection';
|
||||||
|
|
||||||
import {Router, RootRouter} from 'angular2/src/router/router';
|
import {Router, RootRouter} from 'angular2/src/router/router';
|
||||||
import {Pipeline} from 'angular2/src/router/pipeline';
|
|
||||||
import {SpyLocation} from 'angular2/src/mock/location_mock';
|
import {SpyLocation} from 'angular2/src/mock/location_mock';
|
||||||
import {Location} from 'angular2/src/router/location';
|
import {Location} from 'angular2/src/router/location';
|
||||||
import {stringifyInstruction} from 'angular2/src/router/instruction';
|
import {stringifyInstruction} from 'angular2/src/router/instruction';
|
||||||
|
@ -32,14 +31,12 @@ export function main() {
|
||||||
var router, location;
|
var router, location;
|
||||||
|
|
||||||
beforeEachBindings(() => [
|
beforeEachBindings(() => [
|
||||||
Pipeline,
|
|
||||||
RouteRegistry,
|
RouteRegistry,
|
||||||
DirectiveResolver,
|
DirectiveResolver,
|
||||||
bind(Location).toClass(SpyLocation),
|
bind(Location).toClass(SpyLocation),
|
||||||
bind(Router)
|
bind(Router)
|
||||||
.toFactory((registry, pipeline,
|
.toFactory((registry, location) => { return new RootRouter(registry, location, AppCmp); },
|
||||||
location) => { return new RootRouter(registry, pipeline, location, AppCmp); },
|
[RouteRegistry, Location])
|
||||||
[RouteRegistry, Pipeline, Location])
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue