daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top