web-dave / ngrx-workshop

0 stars 1 forks source link

Refactor Actions #47

Open web-dave opened 2 years ago

web-dave commented 2 years ago

Refactor

web-dave commented 2 years ago
CreateAction ## books.actions.ts ```ts export const LoadBooks = createAction(LOAD_BOOKS, props<{ books: IBook[] }>()); export const WaitForBooks = createAction(WAIT_FOR_BOOKS); ```
web-dave commented 2 years ago
Create Reducer ## books.reducer.ts ```ts export const booksReducer = createReducer( initialState, on(LoadBooks, (state, { books }) => bookAdapter.setAll(books, state)) ); ```
web-dave commented 2 years ago
Dispatch ## dispatch ```ts this.store.dispatch(WaitForBooks()); ```