member_webapp/@overflow/meta/store/entity/meta-probe-status/meta-probe-status.effect.ts
crusader 8f6bae5586 ing
2018-05-29 19:49:29 +09:00

40 lines
977 B
TypeScript

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 { MetaProbeStatus } from '@overflow/commons-typescript/model/meta';
import { MetaProbeStatusService } from '../../../service/meta-probe-status.service';
import {
ReadAll,
ReadAllSuccess,
ReadAllFailure,
ActionType,
} from './meta-probe-status.action';
@Injectable()
export class Effects {
constructor(
private actions$: Actions,
private metaProbeStatusService: MetaProbeStatusService,
) { }
@Effect()
readAll$ = this.actions$.pipe(
ofType(ActionType.ReadAll),
exhaustMap(() =>
this.metaProbeStatusService
.readAll()
.pipe(
map((result: MetaProbeStatus[]) => {
return new ReadAllSuccess(result);
}),
catchError(error => of(new ReadAllFailure(error)))
)
)
);
}