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 2x | import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity'; import { createReducer, on } from '@ngrx/store'; import { Wysiwyg } from './wysiwyg'; import * as WysiwygActions from './wysiwyg.actions'; export interface State extends EntityState<Wysiwyg> { } export function selectWysiwygById(wysiwyg: Wysiwyg): string { return wysiwyg.id; } export const adapter: EntityAdapter<Wysiwyg> = createEntityAdapter<Wysiwyg>({ selectId: selectWysiwygById }); export const initialState: State = adapter.getInitialState(); export const reducer = createReducer( initialState, on(WysiwygActions.addWysiwyg, (state, { wysiwyg }) => adapter.addOne(wysiwyg, state)), on(WysiwygActions.saveWysiwyg, (state, { id, content }) => adapter.updateOne({ id, changes: { initialContent: content, content } }, { ...state })), on(WysiwygActions.resetWysiwyg, (state, { id }) => adapter.updateOne({ id, changes: { content: state.entities[id].initialContent } }, { ...state })) ); |