Skip to content
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

Merged

Conversation

evgenyfedorenko
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

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?

[x] Yes
[ ] No

The default option for rooterState in StoreRouterConnectingModule is changing. If still need to support DefaultRouterStateSerializer will need to explicitly pass in RouterState.Full for routerState.

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.

@ngrxbot
Copy link
Collaborator

ngrxbot commented Jan 21, 2020

Preview docs changes for dcf794a at https://previews.ngrx.io/pr2326-dcf794a/

Copy link
Member

@timdeschryver timdeschryver left a 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;
Copy link
Member

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 {
Copy link
Member

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 };
}

}
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

@alex-okrushko alex-okrushko left a 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.

@evgenyfedorenko
Copy link
Contributor Author

updated...

@brandonroberts brandonroberts merged commit ba37ad8 into ngrx:master Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Router Store: make minimal router state serializer the default
5 participants