Skip to content

Commit

Permalink
docs(effects): Remove usage of deprecated toPayload util in example (
Browse files Browse the repository at this point in the history
  • Loading branch information
jayphelps authored and MikeRyanDev committed Sep 19, 2017
1 parent c31573f commit 1ced35a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions docs/effects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@ import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Action } from '@ngrx/store';
import { Actions, Effect, toPayload } from '@ngrx/effects';
import { Actions, Effect } from '@ngrx/effects';
import { of } from 'rxjs/observable/of';

@Injectable()
export class AuthEffects {
// Listen for the 'LOGIN' action
@Effect() login$: Observable<Action> = this.actions$.ofType('LOGIN')
// Map the payload into JSON to use as the request body
.map(toPayload)
.mergeMap(payload =>
this.http.post('/auth', payload)
.mergeMap(action =>
this.http.post('/auth', action.payload)
// If successful, dispatch success action with result
.map(data => ({ type: 'LOGIN_SUCCESS', payload: data }))
// If request fails, dispatch failed action
Expand Down

0 comments on commit 1ced35a

Please sign in to comment.