-
-
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
refactor(router-store): change serializer names #3430
refactor(router-store): change serializer names #3430
Conversation
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.
I was busy reviewing the PR, and I think it's good.
But it also made me thinking, is "default" serializer a good term?
What about keeping minimal en full, and mention in the docs/ts-docs that minimal is the default? This way, it would be easier to make changes to it in the future, and it's also giving more information in comparison to "default".
I think the term minimal and default is now used in combination.
Thoughts?
Regardless of the result, I'll go over the PR once again in more detail.
+1 |
Agreed. Will update. |
✅ Deploy Preview for ngrx-io ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
@@ -6,7 +6,10 @@ export interface SerializedRouterStateSnapshot extends BaseRouterStoreState { | |||
url: string; | |||
} | |||
|
|||
export class DefaultRouterStateSerializer | |||
/** | |||
* @deprecated The FullRouterStateSerializer cannot be used when serializability runtime checks are enabled. Use the {@link MinimalRouterStateSerializer} or a {@link https://ngrx.io/guide/router-store/configuration#custom-router-state-serializer custom serializer} instead. |
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.
I'm not sure we need to deprecate this yet. Deprecation means this could be removed at some point. It's still a valid serializer given its limitations. At some point there was a discussion about making the router state serializable.
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.
Looking good!
Left a few remarks for the docs.
<div class="alert is-important"> | ||
|
||
The `FullRouterStateSerializer` cannot be used when [serializability runtime checks](guide/store/configuration/runtime-checks) are enabled. | ||
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.
We don't freeze Ivy properties anymore, so this isn't correct anymore.
With serializability runtime checks enabled, the `MinimalRouterStateSerializer` serializer **must** be used. This also applies to Ivy with immutability runtime checks. | |
With serializability runtime checks enabled, the `MinimalRouterStateSerializer` serializer **must** be used. |
@@ -39,7 +39,7 @@ export class AppModule {} | |||
|
|||
<div class="alert is-important"> | |||
|
|||
The serializability runtime checks cannot be enabled if you use `@ngrx/router-store` with the `DefaultRouterStateSerializer`. The [default serializer](guide/router-store/configuration) has an unserializable router state and actions that are not serializable. To use the serializability runtime checks either use the `MinimalRouterStateSerializer` or implement a custom router state serializer. | |||
The serializability runtime checks cannot be enabled if you use `@ngrx/router-store` with the `FullRouterStateSerializer`. The [full serializer](guide/router-store/configuration) has an unserializable router state and actions that are not serializable. To use the serializability runtime checks either use the `MinimalRouterStateSerializer` or implement a custom router state serializer. | |||
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.
This also applies to Ivy with immutability runtime checks. |
|
||
When this property is set to `RouterState.Full`, `@ngrx/router-store` will use the `DefaultRouterStateSerializer` serializer to serialize the Angular router event. | ||
`RouterState.Minimal` will use the `MinimalRouterStateSerializer` serializer to serialize the Angular Router's `RouterState` and `RouterEvent`. |
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.
`RouterState.Minimal` will use the `MinimalRouterStateSerializer` serializer to serialize the Angular Router's `RouterState` and `RouterEvent`. | |
`RouterState.Minimal` uses the `MinimalRouterStateSerializer` serializer to serialize the Angular Router's `RouterState` and `RouterEvent`. |
|
||
`RouterState.Minimal` will use the `MinimalRouterStateSerializer` serializer to serialize the Angular Router's `RouterState` and `RouterEvent`. | ||
When this property is set to `RouterState.Full`, `@ngrx/router-store` will use the `FullRouterStateSerializer` serializer to serialize the Angular router event. |
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.
When this property is set to `RouterState.Full`, `@ngrx/router-store` will use the `FullRouterStateSerializer` serializer to serialize the Angular router event. | |
When this property is set to `RouterState.Full`, `@ngrx/router-store` uses the `FullRouterStateSerializer` serializer to serialize the Angular router event. |
|
||
The difference between `MinimalRouterStateSerializer` and the default `RouterStateSerializer` is that this serializer is fully serializable. To make the state and the actions serializable, the properties `paramMap`, `queryParamMap` and `component` are ignored. | ||
The metadata on the action will contain the Angular router event, e.g. `NavigationStart` and `RoutesRecognized`. |
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.
The metadata on the action will contain the Angular router event, e.g. `NavigationStart` and `RoutesRecognized`. | |
The metadata on the action contains the Angular router event, e.g. `NavigationStart` and `RoutesRecognized`. |
@@ -6,7 +6,10 @@ export interface SerializedRouterStateSnapshot extends BaseRouterStoreState { | |||
url: string; | |||
} | |||
|
|||
export class DefaultRouterStateSerializer | |||
/** | |||
* @deprecated The FullRouterStateSerializer cannot be used when serializability runtime checks are enabled. Use the {@link MinimalRouterStateSerializer} or a {@link https://ngrx.io/guide/router-store/configuration#custom-router-state-serializer custom serializer} instead. |
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.
I'm not sure if we should deprecate this.
It's recommended to use the minimal serializer, but some (a lot?) applications have serializability disabled, making this serializer valid.
Thoughts?
* Set to `Full` to use the `FullRouterStateSerializer` and to set the angular router events as payload. | ||
* Set to `Minimal` to use the `MinimalRouterStateSerializer` and to set a minimal router event with the navigation id and url as payload. |
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.
Because minimal is the default now:
* Set to `Full` to use the `FullRouterStateSerializer` and to set the angular router events as payload. | |
* Set to `Minimal` to use the `MinimalRouterStateSerializer` and to set a minimal router event with the navigation id and url as payload. | |
* Set to `Minimal` to use the `MinimalRouterStateSerializer` and to set a minimal router event with the navigation id and url as payload. | |
* Set to `Full` to use the `FullRouterStateSerializer` and to set the angular router events as payload. |
* Full = Serializes the router event with FullRouterStateSerializer | ||
* Minimal = Serializes the router event with MinimalRouterStateSerializer |
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.
* Full = Serializes the router event with FullRouterStateSerializer | |
* Minimal = Serializes the router event with MinimalRouterStateSerializer | |
* Minimal = Serializes the router event with MinimalRouterStateSerializer | |
* Full = Serializes the router event with FullRouterStateSerializer |
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.
👍
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?
Closes #3416
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Includes migration