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:
parent
a443ea64a1
commit
43f97a951c
|
@ -1,7 +1,14 @@
|
||||||
library angular2.src.router.route_config_normalizer;
|
library angular2.src.router.route_config_normalizer;
|
||||||
|
|
||||||
import "route_config_decorator.dart";
|
import "route_config_decorator.dart";
|
||||||
|
import "package:angular2/src/core/facade/exceptions.dart" show BaseException;
|
||||||
|
|
||||||
RouteDefinition normalizeRouteConfig(RouteDefinition config) {
|
RouteDefinition normalizeRouteConfig(RouteDefinition config) {
|
||||||
return 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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {AsyncRoute, AuxRoute, Route, Redirect, RouteDefinition} from './route_config_decorator';
|
import {AsyncRoute, AuxRoute, Route, Redirect, RouteDefinition} from './route_config_decorator';
|
||||||
import {ComponentDefinition} from './route_definition';
|
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';
|
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,3 +47,9 @@ export function normalizeRouteConfig(config: RouteDefinition): RouteDefinition {
|
||||||
|
|
||||||
return config;
|
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.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import {
|
||||||
} from './route_config_impl';
|
} from './route_config_impl';
|
||||||
import {reflector} from 'angular2/src/core/reflection/reflection';
|
import {reflector} from 'angular2/src/core/reflection/reflection';
|
||||||
import {Injectable} from 'angular2/src/core/di';
|
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';
|
import {parser, Url, pathSegmentsToUrl} from './url_parser';
|
||||||
|
|
||||||
var _resolveToNull = PromiseWrapper.resolve(null);
|
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.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue