Skip to content

Commit

Permalink
fix(example): remove custom router state serializer (#1129)
Browse files Browse the repository at this point in the history
V6 of Router Store uses a default serializer that provides a serializable router-state out of the box.
  • Loading branch information
timdeschryver authored and brandonroberts committed Jun 23, 2018
1 parent 068263c commit 389cd78
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 51 deletions.
5 changes: 4 additions & 1 deletion docs/router-store/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export class CustomSerializer implements RouterStateSerializer<RouterStateUrl> {
route = route.firstChild;
}

const { url, root: { queryParams } } = routerState;
const {
url,
root: { queryParams },
} = routerState;
const { params } = route;

// Only return an object including the URL, params and query params
Expand Down
9 changes: 0 additions & 9 deletions example-app/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { AuthModule } from './auth/auth.module';

import { reducers, metaReducers } from './reducers';
import { schema } from './db';
import { CustomRouterStateSerializer } from './shared/utils';

import { AppComponent } from './core/containers/app.component';
import { environment } from '../environments/environment';
Expand Down Expand Up @@ -85,14 +84,6 @@ import { AppRoutingModule } from './app-routing.module';

CoreModule.forRoot(),
],
providers: [
/**
* The `RouterStateSnapshot` provided by the `Router` is a large complex structure.
* A custom RouterStateSerializer is used to parse the `RouterStateSnapshot` provided
* by `@ngrx/router-store` to include only the desired pieces of the snapshot.
*/
{ provide: RouterStateSerializer, useClass: CustomRouterStateSerializer },
],
bootstrap: [AppComponent],
})
export class AppModule {}
3 changes: 1 addition & 2 deletions example-app/app/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
MetaReducer,
} from '@ngrx/store';
import { environment } from '../../environments/environment';
import { RouterStateUrl } from '../shared/utils';
import * as fromRouter from '@ngrx/router-store';

/**
Expand All @@ -31,7 +30,7 @@ import * as fromLayout from '../core/reducers/layout.reducer';
*/
export interface State {
layout: fromLayout.State;
router: fromRouter.RouterReducerState<RouterStateUrl>;
router: fromRouter.RouterReducerState;
}

/**
Expand Down
38 changes: 0 additions & 38 deletions example-app/app/shared/utils.ts

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"coverage:html": "nyc report --reporter=html",
"copy:dist": "ncp dist/ ./node_modules/@ngrx/",
"example:start": "yarn run cli serve",
"example:start:aot": "yarn run cli serve -prod",
"example:start:aot": "yarn run cli serve --prod",
"example:test": "jest --watch",
"example:build:prod": "yarn cli build --prod --base-href \"/platform/example-app/\" --output-path \"./example-dist/example-app\"",
"ci": "yarn run test && nyc report --reporter=text-lcov | coveralls",
Expand Down

0 comments on commit 389cd78

Please sign in to comment.