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

refactor(router-store): change serializer names #3430

Merged

Conversation

david-shortman
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
[ ] Feature
[ ] Code style update (formatting, local variables)
[x] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[x] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes #3416

What is the new behavior?

Does this PR introduce a breaking change?

[x] Yes
[ ] No

Other information

Includes migration

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.

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.

@markostanimirovic
Copy link
Member

What about keeping minimal en full, and mention in the docs/ts-docs that minimal is the default?

+1

@david-shortman
Copy link
Contributor Author

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.

Agreed. Will update.

@netlify
Copy link

netlify bot commented May 30, 2022

Deploy Preview for ngrx-io ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 9c6d631
🔍 Latest deploy log https://app.netlify.com/sites/ngrx-io/deploys/6296b7019d28fe000990641a
😎 Deploy Preview https://deploy-preview-3430--ngrx-io.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

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.

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.

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

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.

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

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?

Comment on lines 75 to 76
* 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.
Copy link
Member

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:

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

Comment on lines 52 to 53
* Full = Serializes the router event with FullRouterStateSerializer
* Minimal = Serializes the router event with MinimalRouterStateSerializer
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
* 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

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.

👍

@brandonroberts brandonroberts merged commit d443f50 into ngrx:master Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename MinimalRouterStateSerializer to DefaultRouterStateSerializer
4 participants