Skip to content

Commit

Permalink
refactor(routes): Rename indexRoute and loadIndexRoute (ngrx#93)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

  `indexRoute` is now `index` and `loadIndexRoute` is now `loadIndex`

  BEFORE:

  ```ts
  const routes: Routes = [
    {
      path: '/',
      component: MarketingTemplateComponent,
      indexRoute: {
        component: HomePageComponent,
      }
    },
    {
      path: '/blog',
      component: BlogComponent,
      loadIndexRoute: () => System.import('app/routes/blog')
    }
  ];
  ```

  AFTER:

  ```ts
  const routes: Routes = [
    {
      path: '/',
      component: MarketingTemplateComponent,
      index: {
        component: HomePageComponent
      }
    },
    {
      path: '/blog',
      component: BlogComponent,
      loadIndex: () => System.import('app/routes/blog')
    }
  ];
  ```
  • Loading branch information
MikeRyanDev authored and brandonroberts committed May 10, 2016
1 parent 08984e2 commit 48dc195
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/route-traverser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class RouteTraverser {
}

private _loadIndexRoute(route: Route): Promise<Route> {
return this._loader.load(route.indexRoute, route.loadIndexRoute, null);
return this._loader.load(route.index, route.loadIndex, null);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export interface IndexRoute extends BaseRoute {
export interface Route extends IndexRoute {
path?: string;
guards?: any[];
indexRoute?: IndexRoute;
loadIndexRoute?: Async<IndexRoute>;
index?: IndexRoute;
loadIndex?: Async<IndexRoute>;
children?: Routes;
loadChildren?: Async<Routes>;
}
Expand Down
10 changes: 5 additions & 5 deletions spec/route-traverser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('RouteTraverser', function() {
children: [
UsersRoute = {
path: 'users',
indexRoute: (UsersIndexRoute = {}),
index: (UsersIndexRoute = {}),
children: [
UserRoute = {
path: ':userID',
Expand Down Expand Up @@ -364,7 +364,7 @@ describe('RouteTraverser', function() {
describe('asynchronous route config', function() {
function makeAsyncRouteConfig(routes: Routes) {
routes.forEach(route => {
const { children, indexRoute } = route;
const { children, index } = route;

if ( children ) {
delete route.children;
Expand All @@ -374,10 +374,10 @@ describe('RouteTraverser', function() {
makeAsyncRouteConfig(children);
}

if ( indexRoute ) {
delete route.indexRoute;
if ( index ) {
delete route.index;

route.loadIndexRoute = () => Promise.resolve(indexRoute);
route.loadIndex = () => Promise.resolve(index);
}
});
}
Expand Down

0 comments on commit 48dc195

Please sign in to comment.