Skip to content

Commit

Permalink
fix(example): handle possible undefined results from Dictionary (#1745)
Browse files Browse the repository at this point in the history
Closes #1735
  • Loading branch information
alex-okrushko authored and brandonroberts committed Apr 13, 2019
1 parent db5c141 commit 861b0cb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions projects/example-app/src/app/books/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as fromSearch from '@example-app/books/reducers/search.reducer';
import * as fromBooks from '@example-app/books/reducers/books.reducer';
import * as fromCollection from '@example-app/books/reducers/collection.reducer';
import * as fromRoot from '@example-app/reducers';
import { Book } from '../models/book';

export interface BooksState {
search: fromSearch.State;
Expand Down Expand Up @@ -122,7 +123,9 @@ export const getSearchResults = createSelector(
getBookEntities,
getSearchBookIds,
(books, searchIds) => {
return searchIds.map(id => books[id]);
return searchIds
.map(id => books[id])
.filter((book): book is Book => book != null);
}
);

Expand All @@ -148,7 +151,9 @@ export const getBookCollection = createSelector(
getBookEntities,
getCollectionBookIds,
(entities, ids) => {
return ids.map(id => entities[id]);
return ids
.map(id => entities[id])
.filter((book): book is Book => book != null);
}
);

Expand Down

0 comments on commit 861b0cb

Please sign in to comment.