All files / src/app/extensions/store-locator/store/stores stores.effects.ts

57.14% Statements 8/14
100% Branches 0/0
0% Functions 0/4
53.84% Lines 7/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 302x 2x 2x   2x   2x   2x     2x                                    
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { concatMap, map } from 'rxjs/operators';
 
import { mapErrorToAction } from 'ish-core/utils/operators';
 
import { StoresService } from '../../services/stores/stores.service';
 
import { loadStores, loadStoresFail, loadStoresSuccess } from './stores.actions';
 
@Injectable()
export class StoresEffects {
  constructor(
    private actions$: Actions,
    private storesService: StoresService
  ) {}
 
  loadStores$ = createEffect(() =>
    this.actions$.pipe(
      ofType(loadStores),
      concatMap(action =>
        this.storesService.getStores(action.payload.countryCode, action.payload.postalCode, action.payload.city).pipe(
          map(stores => loadStoresSuccess({ stores })),
          mapErrorToAction(loadStoresFail)
        )
      )
    )
  );
}