Skip to content

Commit

Permalink
docs(Effects): Tidy examples in effects lifecycle guide
Browse files Browse the repository at this point in the history
  • Loading branch information
zak-cloudnc committed Jan 27, 2020
1 parent 3a9ad63 commit eb9a0c4
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions projects/ngrx.io/content/guide/effects/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Usage:

<code-example header="log.effects.ts">
import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, createEffect } from '@ngrx/effects';
import { tap } from 'rxjs/operators';

@Injectable()
Expand Down Expand Up @@ -64,7 +64,6 @@ import {
LoginPageActions,
AuthApiActions,
} from '../actions';
import { Credentials } from '../models/user';
import { AuthService } from '../services/auth.service';

@Injectable()
Expand Down Expand Up @@ -103,6 +102,7 @@ certain "retryable" errors, or with maximum number of retries.
```ts
import { Observable, throwError } from 'rxjs';
import { retryWhen, mergeMap } from 'rxjs/operators';
import { ErrorHandler, NgModule } from '@angular/core';
import { Action } from '@ngrx/store';
import { EffectsModule, EFFECTS_ERROR_HANDLER } from '@ngrx/effects';
import { MovieEffects } from './effects/movie.effects';
Expand Down Expand Up @@ -167,32 +167,31 @@ By default, effects are merged and subscribed to the store. Implement the `OnRun
Usage:

<code-example header="user.effects.ts">
import { Observable } from 'rxjs';
import { exhaustMap, takeUntil, tap } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import {
Actions,
Effect,
OnRunEffects,
EffectNotification,
ofType,
createEffect,
} from '@ngrx/effects';
import { Action } from '@ngrx/store';
import { Observable } from 'rxjs';
import { exhaustMap, takeUntil, tap } from 'rxjs/operators';

@Injectable()
export class UserEffects implements OnRunEffects {
constructor(private actions$: Actions) {}

updateUser$ = createEffect(() =>
this.actions$.pipe(
ofType('UPDATE_USER'),
tap(action => {
console.log(action);
})
),
{ dispatch: false });

ngrxOnRunEffects(resolvedEffects$: Observable&lt;EffectNotification&gt;) {
this.actions$.pipe(
ofType('UPDATE_USER'),
tap(action => {
console.log(action);
})
),
{ dispatch: false });

ngrxOnRunEffects(resolvedEffects$: Observable<EffectNotification>) {
return this.actions$.pipe(
ofType('LOGGED_IN'),
exhaustMap(() =>
Expand Down

0 comments on commit eb9a0c4

Please sign in to comment.