Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
Reselect - how to pass a result of one selector to another as an argument before combiner function?

I have a selector that looks like this:

export const shipmentsRejectedSelector: (
  state: AppStateType,
  departmentIds: List<number>,
  currentDate: DateTime,
  toDate: DateTime
) => List<Shipment> = createImmutableEqualSelector(
  shipmentsByDepartmentIdsAndDate,
  packageEvents,
  (shipments, events) =>
    shipments
      .valueSeq()
      .filter(s => s.get('state') == EventType.REJECTED))
      ?.toList() || List()
)

Since packageEvents returns all events no matter what shipments it is part of, I would like to return only events that are part of the shipments returned by the shipmentsByDepartmentIdsAndDate selector. How can I pass shipmentIds to a new selector that would fetch only events that have the shipmentIds that I am passing? Something like this for example:

export const shipmentsRejectedSelector: (
      state: AppStateType,
      departmentIds: List<number>,
      currentDate: DateTime,
      toDate: DateTime
    ) => List<Shipment> = createImmutableEqualSelector(
      shipmentsByDepartmentIdsAndDate,
      shipments => packageEvents(shipments),
      (shipments, events) =>
        shipments
          .valueSeq()
          .filter(s => s.get('state') == EventType.REJECTED))
          ?.toList() || List()
    )
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In your code you've not shown how you are using the event object in resultFunc(combiner). So I am guessing you want to add events to the shipments before filtering them.

One way could be to use the packageEvents in combiner:

const shipmentsByDepartmentIdsAndDate = ...;
const shipmentWithPackageEvents = createSelector(shipments, (shipments)=>{//return shipments along with the corresponding events});

const shipmentsRejectedSelector = createSelector(
      shipmentsByDepartmentIdsAndDate,
      (shipments) =>
        shipmentWithPackageEvents(shipments).valueSeq()
          .filter(s => s.get('state') == EventType.REJECTED))
          ?.toList() || List()
    )

Or we can directly use shipmentWithPackageEvents:

const shipmentsByDepartmentIdsAndDate = ...;
const shipmentWithPackageEvents = createSelector(shipments, (shipments)=>{//return shipments along with the corresponding events});

const shipmentsRejectedSelector = createSelector(
      shipmentWithPackageEvents,
      (shipments) =>
        shipments.valueSeq()
          .filter(s => s.get('state') == EventType.REJECTED))
          ?.toList() || List()
    )
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!