You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
600 B
24 lines
600 B
import { createSelector } from 'reselect';
|
|
import AppState from 'App/State/AppState';
|
|
import Author from 'Author/Author';
|
|
|
|
function createMultiAuthorsSelector(authorIds: number[]) {
|
|
return createSelector(
|
|
(state: AppState) => state.authors.itemMap,
|
|
(state: AppState) => state.authors.items,
|
|
(itemMap, allAuthors) => {
|
|
return authorIds.reduce((acc: Author[], authorId) => {
|
|
const author = allAuthors[itemMap[authorId]];
|
|
|
|
if (author) {
|
|
acc.push(author);
|
|
}
|
|
|
|
return acc;
|
|
}, []);
|
|
}
|
|
);
|
|
}
|
|
|
|
export default createMultiAuthorsSelector;
|