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 34 35 36 37 38 | 4x 1x 1x 1x 1x 1x 1x | import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity'; import { createReducer, on } from '@ngrx/store'; import { Modal } from './modal'; import * as ModalActions from './modal.actions'; export interface State extends EntityState<Modal> {} export function selectModalByName(modal: Modal): string { return modal.name; } export const adapter: EntityAdapter<Modal> = createEntityAdapter<Modal>({ selectId: selectModalByName }); export const initialState: State = adapter.getInitialState(); export const reducer = createReducer( initialState, on(ModalActions.addModal, (state, { modal }) => adapter.addOne(modal, state)), on(ModalActions.closeModal, (state, { id }) => adapter.updateOne({ id, changes: { open: false } }, { ...state })), on(ModalActions.openModal, (state, { id }) => adapter.updateOne({ id, changes: { open: true } }, { ...state })) ); |