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 | 241x 241x 241x 241x 241x 241x 241x 1x 3x 1x 1x | import { createSelector } from '@ngrx/store';
import { Region } from 'ish-core/models/region/region.model';
import { getGeneralState } from 'ish-core/store/general/general-store';
import { regionAdapter } from './regions.reducer';
const getRegionsState = createSelector(getGeneralState, state => state.regions);
export const { selectAll: getAllRegions } = regionAdapter.getSelectors(getRegionsState);
export const getRegionsLoading = createSelector(getRegionsState, regions => regions.loading);
export const getRegionsByCountryCode = (countryCode: string) =>
createSelector(getAllRegions, getRegionsLoading, (entities, loading): Region[] => {
const regionsForCountry = entities.filter(e => e.countryCode === countryCode);
// when still loading, do not return empty array because we can't be sure there are no regions
Iif (loading && !regionsForCountry.length) {
return;
}
return regionsForCountry;
});
|