Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Injectable } from '@angular/core';
- import { Actions, Effect, ofType } from '@ngrx/effects';
- import { EMPTY } from 'rxjs';
- import { map, mergeMap } from 'rxjs/operators';
- @Injectable()
- export class MovieEffects {
- @Effect()
- loadMovies$ = this.actions$
- .pipe(
- // Определяем тип события
- ofType('[Login Page] Login'),
- // Выполняем запрос к серверу
- mergeMap((action) => this.authService.login(action.payload)
- .pipe(
- // Получаем ответ и отправляем новое событие
- map(movies => ({ type: '[Login Page] Login Success', payload: posts })),
- catchError(() => EMPTY)
- ))
- )
- );
- constructor(
- private actions$: Actions,
- private moviesService: MoviesService
- ) {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement