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';
|
|
|
|
|
2018-05-29 10:49:29 +00:00
|
|
|
import { MetaProbeOs } from '@overflow/commons-typescript/model/meta';
|
|
|
|
|
2018-05-29 10:17:16 +00:00
|
|
|
import { MetaProbeOsService } from '../../../service/meta-probe-os.service';
|
|
|
|
|
|
|
|
import {
|
|
|
|
ReadAll,
|
|
|
|
ReadAllSuccess,
|
|
|
|
ReadAllFailure,
|
|
|
|
ActionType,
|
|
|
|
} from './meta-probe-os.action';
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class Effects {
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
private actions$: Actions,
|
|
|
|
private metaProbeOsService: MetaProbeOsService,
|
|
|
|
) { }
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
readAll$ = this.actions$.pipe(
|
|
|
|
ofType(ActionType.ReadAll),
|
|
|
|
exhaustMap(() =>
|
|
|
|
this.metaProbeOsService
|
|
|
|
.readAll()
|
|
|
|
.pipe(
|
|
|
|
map((result: MetaProbeOs[]) => {
|
|
|
|
return new ReadAllSuccess(result);
|
|
|
|
}),
|
|
|
|
catchError(error => of(new ReadAllFailure(error)))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|