-
-
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
docs: few tweaks to the migration guide #3649
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,14 @@ Version 15 has the minimum version requirements: | |
|
||
### @ngrx/store | ||
|
||
#### Strict Selector Projector | ||
|
||
The projector function on the selector is type-safe by default. | ||
The projector function also has become strict for selectors with props. | ||
|
||
BEFORE: | ||
|
||
The projector is not type-safe by default, allowing for potential mismatch types in the projector function. | ||
The projector is not type-safe, allowing for potential mismatch types in the projector function. | ||
|
||
```ts | ||
const mySelector = createSelector( | ||
|
@@ -41,7 +44,7 @@ mySelector.projector() // <- type is projector(...args: any[]): number | |
|
||
AFTER: | ||
|
||
The projector is strict by default, but can be bypassed with an `any` generic parameter. | ||
The projector is strict by default, but can be bypassed with an `any` type assertion to specify a less specific type. | ||
|
||
```ts | ||
const mySelector = createSelector( | ||
|
@@ -65,95 +68,53 @@ const mySelector = createSelector( | |
(mySelector.projector as any)() | ||
``` | ||
|
||
The projector method has become strict for selectors with props | ||
|
||
BEFORE: | ||
|
||
You could pass any arguments to the projector method | ||
|
||
```ts | ||
const selector = createSelector( | ||
selectString, // returning a string | ||
selectNumber, // returning a number | ||
(s, n, prefix: string) => { | ||
return prefix + s.repeat(n); | ||
} | ||
) | ||
|
||
// you could pass any argument | ||
selector.projector(1, 'a', true); | ||
``` | ||
|
||
AFTER: | ||
|
||
```ts | ||
const selector = createSelector( | ||
selectString, // returning a string | ||
selectNumber, // returning a number | ||
(s, n, prefix: string) => { | ||
return prefix + s.repeat(n); | ||
} | ||
) | ||
### @ngrx/effects | ||
|
||
// this throws | ||
selector.projector(1, 'a', true); | ||
// this does not throw because the arguments have the correct type | ||
selector.projector(1, 'a', 'prefix'); | ||
``` | ||
#### Removal of @Effect | ||
|
||
### @ngrx/effects | ||
The `@Effect` decorator is removed in favor of [`createEffect`](api/effects/createEffect). | ||
This change also means that the ESLint rules @ngrx/no-effect-decorator-and-creator and @ngrx/no-effect-decorator are removed. | ||
|
||
The @Effect decorator is removed | ||
> A migration was added (in the v13 release) to upgrade existing codebases to the `createEffect` function. | ||
|
||
BEFORE: | ||
|
||
Defining an effect is done with @Effect | ||
An effect is defined with the `@Effect` decorator. | ||
|
||
```ts | ||
@Effect() | ||
data$ = this.actions$.pipe(); | ||
``` | ||
|
||
A migration was added in the v13 release to upgrade existing codebases to the `createEffect` function. | ||
|
||
AFTER: | ||
|
||
Defining an effect is done with createEffect | ||
You need to define an effect with `createEffect`. | ||
|
||
```ts | ||
data$ = createEffect(() => this.actions$.pipe()); | ||
``` | ||
|
||
The signature of `provideEffects` is changed to expect a | ||
spreaded array of effects. | ||
### @ngrx/router-store | ||
|
||
BEFORE: | ||
#### Title | ||
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. Introduced in #3648 |
||
|
||
`provideEffects` expected the effects to be passed as an array. | ||
timdeschryver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
BREAKING CHANGE: | ||
|
||
```ts | ||
// single effect | ||
provideEffects([MyEffect]) | ||
The property `title: string | undefined` is added to the `MinimalActivatedRouteSnapshot` interface when a title added to the route config. | ||
|
||
// multiple effects | ||
provideEffects([MyEffect, MySecondEffect]) | ||
```ts | ||
BEFORE: | ||
|
||
AFTER: | ||
The `MinimalActivatedRouteSnapshot` interface doesn't contain the `title` property. | ||
|
||
`provideEffects` expects the effects as a spreaded array as argument. | ||
AFTER: | ||
|
||
```ts | ||
// single effect | ||
provideEffects(MyEffect) | ||
The `MinimalActivatedRouteSnapshot` interface contains the required `title` property. | ||
|
||
// multiple effects | ||
provideEffects(MyEffect, MySecondEffect) | ||
``` | ||
### @ngrx/component | ||
|
||
## @ngrx/component | ||
#### Removal of ReactiveComponentModule | ||
|
||
`ReactiveComponentModule` is removed in favor of `LetModule` and `PushModule`. | ||
The `ReactiveComponentModule` is removed in favor of [`LetModule`](/api/component/LetModule) and [`PushModule`](/api/component/PushModule). | ||
|
||
BEFORE: | ||
|
||
|
@@ -182,3 +143,4 @@ import { LetModule, PushModule } from '@ngrx/component'; | |
], | ||
}) | ||
export class MyFeatureModule {} | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Updated the description because we didn't implement the
any
type generic