Skip to content
This repository has been archived by the owner on Jan 15, 2023. It is now read-only.

Commit

Permalink
feat: add enter page handler to example app
Browse files Browse the repository at this point in the history
  • Loading branch information
markostanimirovic committed Dec 8, 2020
1 parent 1ef1990 commit 9b4a0bd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion projects/playground/src/app/books/books.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class BooksComponent implements OnInit, OnDestroy {
constructor(private store: Store<BooksAppState>) {}

ngOnInit(): void {
this.store.dispatch(booksPageActions.updateSearchTerm({ searchTerm: '' }));
this.store.dispatch(booksPageActions.enter());

this.searchTermControl.valueChanges
.pipe(debounceTime(300), distinctUntilChanged(), takeUntil(this.destroy))
Expand Down
2 changes: 1 addition & 1 deletion projects/playground/src/app/books/books.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { selectBooks } from './books.selectors';
export class BooksEffects {
invokeFetchBooks$ = createEffect(() =>
this.actions$.pipe(
ofType(booksPageActions.updateSearchTerm),
ofType(booksPageActions.enter, booksPageActions.updateSearchTerm),
map(() => booksEffectsActions.fetchBooks()),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { booksInitState } from '../books.state';
import { Book } from '../book.model';

export const [booksPageActions, booksPageReducer] = combineHandlers(booksInitState, 'booksPage', {
enter: state => ({ ...state, searchTerm: '' }),
updateSearchTerm: (state, { searchTerm }: { searchTerm: string }) => ({ ...state, searchTerm }),
showCreateBookDialog: plain(),
createBook: withPayload<{ book: Book }>(),
Expand Down

0 comments on commit 9b4a0bd

Please sign in to comment.