Skip to content

Commit

Permalink
fix: prevent triggering the countries call more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
SGrueber committed Aug 12, 2024
1 parent 818a32b commit 8479bdf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/core/store/general/countries/countries.effects.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Actions, concatLatestFrom, createEffect, ofType } from '@ngrx/effects';
import { Store, select } from '@ngrx/store';
import { filter, map, switchMap } from 'rxjs/operators';
import { exhaustMap, filter, map } from 'rxjs/operators';

import { CountryService } from 'ish-core/services/country/country.service';
import { mapErrorToAction } from 'ish-core/utils/operators';
Expand All @@ -18,7 +18,7 @@ export class CountriesEffects {
ofType(loadCountries),
concatLatestFrom(() => this.store.pipe(select(getAllCountries))),
filter(([, countries]) => !countries.length),
switchMap(() =>
exhaustMap(() =>
this.countryService.getCountries().pipe(
map(countries => loadCountriesSuccess({ countries })),
mapErrorToAction(loadCountriesFail)
Expand Down

0 comments on commit 8479bdf

Please sign in to comment.