member_webapp/@overflow/meta/store/entity/meta-crawler/meta-crawler.effect.ts

44 lines
999 B
TypeScript
Raw Normal View History

2018-05-29 10:17:16 +00:00
import { Injectable } from '@angular/core';
2018-05-29 10:49:29 +00:00
import { of } from 'rxjs';
2018-05-29 10:17:16 +00:00
import { Effect, Actions, ofType } from '@ngrx/effects';
2018-05-29 10:49:29 +00:00
import { catchError, exhaustMap, map, tap } from 'rxjs/operators';
2018-05-29 10:17:16 +00:00
import { MetaCrawler } from '@overflow/commons-typescript/model/meta';
import { MetaCrawlerService } from '../../../service/meta-crawler.service';
import {
ReadAll,
ReadAllSuccess,
ReadAllFailure,
ActionType,
} from './meta-crawler.action';
import {
MetaCrawlerEntitySelector,
} from '../../';
@Injectable()
export class Effects {
constructor(
private actions$: Actions,
private metaCrawlerService: MetaCrawlerService,
) { }
@Effect()
readAll$ = this.actions$.pipe(
ofType(ActionType.ReadAll),
2018-05-29 10:49:29 +00:00
exhaustMap(() =>
this.metaCrawlerService
2018-05-29 10:17:16 +00:00
.readAll()
.pipe(
map((result: MetaCrawler[]) => {
return new ReadAllSuccess(result);
}),
catchError(error => of(new ReadAllFailure(error)))
2018-05-29 10:49:29 +00:00
)
2018-05-29 10:17:16 +00:00
)
);
}