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

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