| /******************************************************************************** |
| * Copyright (c) 2020 Contributors to the Eclipse Foundation |
| * |
| * See the NOTICE file(s) distributed with this work for additional |
| * information regarding copyright ownership. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| ********************************************************************************/ |
| import 'rxjs/add/operator/catch'; |
| import 'rxjs/add/operator/map'; |
| import 'rxjs/add/operator/switchMap'; |
| import { Injectable } from '@angular/core'; |
| import { createEffect, Actions, ofType } from '@ngrx/effects'; |
| import { of } from 'rxjs/observable/of'; |
| import * as gridFailureActions from '@shared/store/actions/grid-failures.action'; |
| import { GridFailureApiClient } from '@pages/grid-failure/grid-failure-api-client'; |
| import { catchError, map, switchMap } from 'rxjs/operators'; |
| import { Store } from '@ngrx/store'; |
| |
| @Injectable() |
| export class GridFailuresEffects { |
| getGridFailures$: any = createEffect(() => |
| this._actions$.pipe( |
| ofType(gridFailureActions.loadGridFailures), |
| switchMap(() => { |
| return this._apiClient.getGridFailures().pipe( |
| map(item => gridFailureActions.loadGridFailuresSuccess({ payload: item })), |
| catchError(error => of(gridFailureActions.loadGridFailuresFail({ payload: error }))) |
| ); |
| }) |
| ) |
| ); |
| |
| constructor(private _actions$: Actions, private _apiClient: GridFailureApiClient, private _store: Store<any>) {} |
| } |