Skip to content

Commit 389cd78

Browse files
timdeschryverbrandonroberts
authored andcommitted
fix(example): remove custom router state serializer (#1129)
V6 of Router Store uses a default serializer that provides a serializable router-state out of the box.
1 parent 068263c commit 389cd78

File tree

5 files changed

+6
-51
lines changed

5 files changed

+6
-51
lines changed

docs/router-store/api.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ export class CustomSerializer implements RouterStateSerializer<RouterStateUrl> {
128128
route = route.firstChild;
129129
}
130130

131-
const { url, root: { queryParams } } = routerState;
131+
const {
132+
url,
133+
root: { queryParams },
134+
} = routerState;
132135
const { params } = route;
133136

134137
// Only return an object including the URL, params and query params

example-app/app/app.module.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { AuthModule } from './auth/auth.module';
1818

1919
import { reducers, metaReducers } from './reducers';
2020
import { schema } from './db';
21-
import { CustomRouterStateSerializer } from './shared/utils';
2221

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

8685
CoreModule.forRoot(),
8786
],
88-
providers: [
89-
/**
90-
* The `RouterStateSnapshot` provided by the `Router` is a large complex structure.
91-
* A custom RouterStateSerializer is used to parse the `RouterStateSnapshot` provided
92-
* by `@ngrx/router-store` to include only the desired pieces of the snapshot.
93-
*/
94-
{ provide: RouterStateSerializer, useClass: CustomRouterStateSerializer },
95-
],
9687
bootstrap: [AppComponent],
9788
})
9889
export class AppModule {}

example-app/app/reducers/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
MetaReducer,
77
} from '@ngrx/store';
88
import { environment } from '../../environments/environment';
9-
import { RouterStateUrl } from '../shared/utils';
109
import * as fromRouter from '@ngrx/router-store';
1110

1211
/**
@@ -31,7 +30,7 @@ import * as fromLayout from '../core/reducers/layout.reducer';
3130
*/
3231
export interface State {
3332
layout: fromLayout.State;
34-
router: fromRouter.RouterReducerState<RouterStateUrl>;
33+
router: fromRouter.RouterReducerState;
3534
}
3635

3736
/**

example-app/app/shared/utils.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"coverage:html": "nyc report --reporter=html",
1515
"copy:dist": "ncp dist/ ./node_modules/@ngrx/",
1616
"example:start": "yarn run cli serve",
17-
"example:start:aot": "yarn run cli serve -prod",
17+
"example:start:aot": "yarn run cli serve --prod",
1818
"example:test": "jest --watch",
1919
"example:build:prod": "yarn cli build --prod --base-href \"/platform/example-app/\" --output-path \"./example-dist/example-app\"",
2020
"ci": "yarn run test && nyc report --reporter=text-lcov | coveralls",

0 commit comments

Comments
 (0)