refactor(router): move assertComponentExists into facade

This is to make way for a refactor to the ng 1.x router directives,
which will use strings rather than controller functions in route configs.
This commit is contained in:
Brian Ford 2015-09-18 15:41:02 -07:00
parent a443ea64a1
commit 43f97a951c
3 changed files with 15 additions and 8 deletions

View File

@ -1,7 +1,14 @@
library angular2.src.router.route_config_normalizer;
import "route_config_decorator.dart";
import "package:angular2/src/core/facade/exceptions.dart" show BaseException;
RouteDefinition normalizeRouteConfig(RouteDefinition config) {
return config;
}
void assertComponentExists(Type component, String path) {
if (component == null) {
throw new BaseException('Component for route "${path}" is not defined, or is not a class.');
}
}

View File

@ -1,6 +1,6 @@
import {AsyncRoute, AuxRoute, Route, Redirect, RouteDefinition} from './route_config_decorator';
import {ComponentDefinition} from './route_definition';
import {Type} from 'angular2/src/core/facade/lang';
import {isType, Type} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
@ -47,3 +47,9 @@ export function normalizeRouteConfig(config: RouteDefinition): RouteDefinition {
return config;
}
export function assertComponentExists(component: Type, path: string): void {
if (!isType(component)) {
throw new BaseException(`Component for route "${path}" is not defined, or is not a class.`);
}
}

View File

@ -31,7 +31,7 @@ import {
} from './route_config_impl';
import {reflector} from 'angular2/src/core/reflection/reflection';
import {Injectable} from 'angular2/src/core/di';
import {normalizeRouteConfig} from './route_config_nomalizer';
import {normalizeRouteConfig, assertComponentExists} from './route_config_nomalizer';
import {parser, Url, pathSegmentsToUrl} from './url_parser';
var _resolveToNull = PromiseWrapper.resolve(null);
@ -318,9 +318,3 @@ function assertTerminalComponent(component, path) {
}
}
}
function assertComponentExists(component: Type, path: string): void {
if (!isType(component)) {
throw new BaseException(`Component for route "${path}" is not defined, or is not a class.`);
}
}