reselect icon indicating copy to clipboard operation
reselect copied to clipboard

Can this be used to group items?

Open pke opened this issue 10 years ago • 1 comments

Lets say this is my state:

{ 
  hotels: [], 
  offices: [],
  stores: [],
  typeFilter: ['hotels', 'stores'] 
}

can reselect be used to select a combined list of items out of ´hotels, offices and stores´ based on the types specified in typeFilter and and that match a keyword search, sorted and grouped by distance? Given that for each item a distance to the users position can be calculated the final list would include cities and stores:

groupedFilteredItems: {
  near: [
    {
      type: "store",
      distance: "10",
    }
  ],
  inWalkingDistance: [
    {
      type: "hotel",
      distance: "1000",      
    }
  ],
  far: [
   {
      type: "store",
      distance: "4000"
   }
  ]
}

pke avatar Dec 16 '15 13:12 pke

Reselect won't help with writing the filtering, grouping and sorting code, but if the transformation is expensive it might be worth using Reselect for memoization to avoid unnecessary recomputations.

ellbee avatar Dec 17 '15 20:12 ellbee