Slide 23
Slide 23 text
import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity';
export interface State extends EntityState { }
export const adapter: EntityAdapter = createEntityAdapter();
export const initialState: State = adapter.getInitialState({ });
export function reducer(state = initialState, action: TodoActions): State {
switch (action.type) {
case TodoActionTypes.CreateTodoSuccess: {
return adapter.addOne(action.payload.todo, { ...state, loading: false });
}
}
@ngrx/entity