issues
search
web-dave
/
ngrx-workshop
0
stars
1
forks
source link
Explore the new Adapter and fix all issues
#15
Open
web-dave
opened
5 years ago
web-dave
commented
5 years ago
Use the new Adapter Methods in
Selector
Reducer
web-dave
commented
5 years ago
Adaptor Selector
```ts const { selectAll, selectEntities, selectIds, selectTotal } = bookAdapter.getSelectors(); export const getBooksSelector = createSelector( createFeatureSelector(booksStoreName), selectAll ); export const getBookSelector = (isbn: string) => createSelector( createFeatureSelector(bookStoreName), (state: IBooksState) => selectEntities(state)[isbn] ); ```
web-dave
commented
5 years ago
Adapter Reducer
```ts case LOAD_BOOKS: return bookAdapter.setAll(action.books, state); ```
web-dave
commented
5 years ago
#### Fix the Adapter to select by isbn
```ts export const bookAdapter = createEntityAdapter
({ selectId: book => book.isbn });
web-dave
commented
2 years ago
NEXT