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 30 31 32 33 | 220x 220x 220x 220x 220x 6x 220x 220x 1x 1x | import { EntityState, createEntityAdapter } from '@ngrx/entity'; import { createReducer, on } from '@ngrx/store'; import { Region } from 'ish-core/models/region/region.model'; import { setLoadingOn, unsetLoadingOn } from 'ish-core/utils/ngrx-creators'; import { loadRegions, loadRegionsFail, loadRegionsSuccess } from './regions.actions'; export const regionAdapter = createEntityAdapter<Region>({ selectId: region => region.id, }); export interface RegionsState extends EntityState<Region> { loading: boolean; } const initialState: RegionsState = regionAdapter.getInitialState({ loading: false, }); export const regionsReducer = createReducer( initialState, setLoadingOn(loadRegions), unsetLoadingOn(loadRegionsFail, loadRegionsSuccess), on(loadRegionsSuccess, (state, action) => { const { regions } = action.payload; return { ...regionAdapter.upsertMany(regions, state), }; }) ); |