-
-
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
feat(router): enabling MinimalRouterStateSerializer by default #2326
Conversation
…ter setup module Closes ngrx#2225
Preview docs changes for dcf794a at https://previews.ngrx.io/pr2326-dcf794a/ |
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.
Changes LGTM, but I have some docs comments.
Could you also update the line https://github.com/ngrx/platform/pull/2326/files#diff-8394e314f48c3713d48bf5c1946b3f23R13:
- `serializer`: How a router snapshot is serialized. Defaults to `DefaultRouterStateSerializer` (see [Default Router State Serializer](#default-router-state-serializer)). See [Custom Router State Serializer](#custom-router-state-serializer) for more information.
url: string; | ||
params: Params; | ||
queryParams: Params; | ||
url: string; |
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.
Seems like something weird has happened here with the formation, could you revert this change please?
} | ||
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
And here
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. |
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.
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. | |
With serializability runtime checks enabled, the `MinimalRouterStateSerializer` serializer **must** be used. This also applies to Ivy with immutability runtime checks. |
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.
👍
Once the comments from Tim are addressed - it is good to go.
updated... |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
If no router state serializer is provided through the configuration of router store, the DefaultRouterStateSerializer is used.
Closes #2225
What is the new behavior?
If no router state serializer is provided through the configuration of router store, the MinimalRouterStateSerializer is used.
Does this PR introduce a breaking change?
The default option for
rooterState
inStoreRouterConnectingModule
is changing. If still need to supportDefaultRouterStateSerializer
will need to explicitly pass inRouterState.Full
forrouterState
.Other information
It is very confusing to me that
serializer
which is set in_createRouterConfig
does not play any effect right now. @timdeschryver said that it was done for backward compatibility reasons and probably will be addressed in another PR by @alex-okrushko. If not, we can discuss here how to make it better.