Skip to content

Instantly share code, notes, and snippets.

@alex-okrushko
Created May 31, 2019 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-okrushko/d6a186dd633a583e1375b0fe708c8e08 to your computer and use it in GitHub Desktop.
Save alex-okrushko/d6a186dd633a583e1375b0fe708c8e08 to your computer and use it in GitHub Desktop.
export const initialState: State = adapter.getInitialState({
selectedBookId: null,
});
export const reducer = createReducer(
initialState,
on(
BooksApiActions.searchSuccess,
CollectionApiActions.loadBooksSuccess,
(state, { books }) => adapter.addMany(books, state)
),
on(BookActions.loadBook, (state, { book }) => adapter.addOne(book, state)),
on(ViewBookPageActions.selectBook, (state, { id }) => ({
...state,
selectedBookId: id,
}))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment