Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import { Injectable } from '@angular/core';
  2. import { Actions, Effect, ofType } from '@ngrx/effects';
  3. import { EMPTY } from 'rxjs';
  4. import { map, mergeMap } from 'rxjs/operators';
  5.  
  6. @Injectable()
  7. export class MovieEffects {
  8.  
  9. @Effect()
  10. loadMovies$ = this.actions$
  11. .pipe(
  12. // Определяем тип события
  13. ofType('[Login Page] Login'),
  14. // Выполняем запрос к серверу
  15. mergeMap((action) => this.authService.login(action.payload)
  16. .pipe(
  17. // Получаем ответ и отправляем новое событие
  18. map(movies => ({ type: '[Login Page] Login Success', payload: posts })),
  19. catchError(() => EMPTY)
  20. ))
  21. )
  22. );
  23.  
  24. constructor(
  25. private actions$: Actions,
  26. private moviesService: MoviesService
  27. ) {}
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement