reselect
reselect copied to clipboard
Can this be used to group items?
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"
}
]
}
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.