-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(router): enabling MinimalRouterStateSerializer by default #2326
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,12 @@ interface StoreRouterConfig { | |
|
||
## Default Router State Serializer | ||
|
||
If no router state serializer is provided through the [configuration](#configuration-options) of router store, the `DefaultRouterStateSerializer` is used. This router state serializer, serializes the URL together with the [ActivatedRouteSnapshot](https://angular.io/api/router/ActivatedRouteSnapshot) from [Angular Router](https://angular.io/guide/router). The latter is serialized recursively, but only with the possibility to traverse the route downward since `root` and `parent` parameters are set to `undefined`. | ||
`DefaultRouterStateSerializer` router state serializer, serializes the URL together with the [ActivatedRouteSnapshot](https://angular.io/api/router/ActivatedRouteSnapshot) from [Angular Router](https://angular.io/guide/router). The latter is serialized recursively, but only with the possibility to traverse the route downward since `root` and `parent` parameters are set to `undefined`. | ||
|
||
<div class="alert is-important"> | ||
|
||
The `DefaultRouterStateSerializer` cannot be used when [serializability runtime checks](guide/store/configuration/runtime-checks) are enabled. If you want to use runtime checks to enforce serializability of your state and actions, you can configure `RouterStoreModule` to use the `MinimalRouterStateSerializer` or implement a custom router state serializer. | ||
This also applies to Ivy with immutability runtime checks. | ||
The `DefaultRouterStateSerializer` cannot be used when [serializability runtime checks](guide/store/configuration/runtime-checks) are enabled. | ||
With runtime checks enabled `MinimalRouterStateSerializer` serializer is used by default in `RouterStoreModule` when no other serializer is provided. This also applies to Ivy with immutability runtime checks. | ||
|
||
</div> | ||
|
||
|
@@ -41,14 +41,14 @@ import { Params, RouterStateSnapshot } from '@angular/router'; | |
import { RouterStateSerializer } from '@ngrx/router-store'; | ||
|
||
export interface RouterStateUrl { | ||
url: string; | ||
params: Params; | ||
queryParams: Params; | ||
url: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like something weird has happened here with the formation, could you revert this change please? |
||
params: Params; | ||
queryParams: Params; | ||
} | ||
|
||
export class CustomSerializer implements RouterStateSerializer<RouterStateUrl> { | ||
serialize(routerState: RouterStateSnapshot): RouterStateUrl { | ||
let route = routerState.root; | ||
serialize(routerState: RouterStateSnapshot): RouterStateUrl { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
let route = routerState.root; | ||
|
||
while (route.firstChild) { | ||
route = route.firstChild; | ||
|
@@ -63,7 +63,8 @@ export class CustomSerializer implements RouterStateSerializer<RouterStateUrl | |
// Only return an object including the URL, params and query params | ||
// instead of the entire snapshot | ||
return { url, params, queryParams }; | ||
} | ||
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
} | ||
</code-example> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.