issues
search
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
Actions and use the creator Functions.
Reducer. set type of action to
any
dispatch of action is now a methos not a class
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()); ```
Refactor
any