Elior Sastiel
Elior Sastiel

Reputation: 1124

createSelector function can get until 9 parameters

I created a new selector:

const getInquiryBasicInfo = createSelector(
getMedia(getInquiryRelatedEntities, ConnectionTypes.InquiryMedia.name),
getJournalist(getInquiryRelatedEntities, ConnectionTypes.InquiryReporter.name),
getReceiveDate,
getResponsDate,
getMediaOutlet,
getInitiatedCount(getInquiryDetails),
getNumberOfPublication(getInquiryDetails),
getPrecedent(getInquiryDetails),
getMinRoleTitle(getInquiryDetails),
getLanguage,
(media, journalist ,receiveDate, responsDate, mediaOutlet, initiatedCount, numberOfPublication ,isPrecedent,role, languages) => {
    return [media,journalist,receiveDate, responsDate, mediaOutlet, initiatedCount,numberOfPublication,isPrecedent ,role, languages].filter(info => {
        return info.value.length;
    });
}

);

and I'm getting this error:

 error TS2554: Expected 2-9 arguments, but got 11.

how can I use createSelector function with more than 9 parameters? I using angular 8 and I used: {createSelector } from '@ngrx/store';

Thanks for any help!

Upvotes: 3

Views: 1437

Answers (1)

timdeschryver
timdeschryver

Reputation: 15507

From my understanding it should fallback to a fallback selector that allows all selectors:

export function createSelector(
  ...input: any[]
): MemoizedSelector<any, any> | MemoizedSelectorWithProps<any, any, any> {
  return createSelectorFactory(defaultMemoize)(...input);
}

That being said having selectors this large is usually a bad practice, and you should split them up in to multiple smaller selectors.

Upvotes: 1

Related Questions