feat(router): allow async routes to be defined with "loader"

This commit is contained in:
Brian Ford
2015-10-08 12:27:55 -07:00
parent 6d4bd5d901
commit ee32b1bc37
2 changed files with 29 additions and 1 deletions

View File

@ -13,10 +13,13 @@ export function normalizeRouteConfig(config: RouteDefinition): RouteDefinition {
return <RouteDefinition>config;
}
if ((!config.component) == (!config.redirectTo)) {
if ((+!!config.component) + (+!!config.redirectTo) + (+!!config.loader) != 1) {
throw new BaseException(
`Route config should contain exactly one "component", "loader", or "redirectTo" property.`);
}
if (config.loader) {
return new AsyncRoute({path: config.path, loader: config.loader, as: config.as});
}
if (config.component) {
if (typeof config.component == 'object') {
let componentDefinitionObject = <ComponentDefinition>config.component;