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 | 220x 220x 220x 220x 2x 220x 220x 1x 1x | import { EntityState, createEntityAdapter } from '@ngrx/entity'; import { createReducer, on } from '@ngrx/store'; import { Country } from 'ish-core/models/country/country.model'; import { loadCountriesFail, loadCountriesSuccess } from './countries.actions'; export const countryAdapter = createEntityAdapter<Country>({ selectId: country => country.countryCode, }); export type CountriesState = EntityState<Country>; const initialState: CountriesState = countryAdapter.getInitialState({}); export const countriesReducer = createReducer( initialState, on( loadCountriesFail, (state): CountriesState => ({ ...state, }) ), on(loadCountriesSuccess, (state, action) => { const { countries } = action.payload; return countryAdapter.setAll(countries, state); }) ); |