Skip to content

Commit

Permalink
feat(effects): deprecate @effect decorator (#2855)
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored Jan 7, 2021
1 parent 06aefb1 commit dbd1ecf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/effects/src/effect_decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { getSourceForInstance } from './utils';

const METADATA_KEY = '__@ngrx/effects__';

/**
* @deprecated The Effect decorator (`@Effect`) is deprecated in favor for the `createEffect` method.
* See the docs for more info {@link https://ngrx.io/guide/migration/v11#the-effect-decorator}
*/
export function Effect(config: EffectConfig = {}) {
return function <T extends Object, K extends EffectPropertyKey<T>>(
target: T,
Expand Down
31 changes: 31 additions & 0 deletions projects/ngrx.io/content/guide/migration/v11.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,34 @@ router state:
}
*/
```

## Deprecations

### @ngrx/effects

#### The Effect decorator

The Effect decorator, `@Effect`, is deprecated in favor for the `createEffect` method.

See the [docs](/guide/effects#writing-effects) for more info.

BEFORE:

```ts
@Effect()
login$ = this.actions$.pipe(...);
```

AFTER:

```ts
login$ = createEffect(() => {
return this.actions$.pipe(...);
});
```

To automatically migrate `@Effect` usages to the `createEffect` method, run the following NgRx migration:

```sh
ng generate @ngrx/schematics:create-effect-migration
```

0 comments on commit dbd1ecf

Please sign in to comment.