member_webapp/@overflow/meta/store/entity/meta-probe-version/meta-probe-version.effect.ts

39 lines
984 B
TypeScript
Raw Normal View History

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