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 | 119x 119x 119x 119x 119x 6x 119x 119x 3x | import { EntityState, createEntityAdapter } from '@ngrx/entity'; import { createReducer, on } from '@ngrx/store'; import { HttpError } from 'ish-core/models/http-error/http-error.model'; import { Warranty } from 'ish-core/models/warranty/warranty.model'; import { setErrorOn, setLoadingOn, unsetLoadingAndErrorOn } from 'ish-core/utils/ngrx-creators'; import { warrantyActions, warrantyApiActions } from './warranties.actions'; export const warrantiesAdapter = createEntityAdapter<Warranty>({ selectId: warranty => warranty.id, }); export interface WarrantiesState extends EntityState<Warranty> { loading: boolean; error: HttpError; } const initialState: WarrantiesState = warrantiesAdapter.getInitialState({ loading: false, error: undefined, }); export const warrantiesReducer = createReducer( initialState, setLoadingOn(warrantyActions.loadWarranty), setErrorOn(warrantyApiActions.loadWarrantyFail), unsetLoadingAndErrorOn(warrantyApiActions.loadWarrantySuccess), on(warrantyApiActions.loadWarrantySuccess, (state, action) => warrantiesAdapter.upsertOne(action.payload.warranty, state) ) ); |