Skip to content

Instantly share code, notes, and snippets.

@ylastapis
Created November 19, 2019 14:29
Show Gist options
  • Save ylastapis/14547ff897728852c5e5f3adb3dc8267 to your computer and use it in GitHub Desktop.
Save ylastapis/14547ff897728852c5e5f3adb3dc8267 to your computer and use it in GitHub Desktop.
Change default memoize function of createSelector in reselect
import { createSelector, createSelectorCreator, defaultMemoize } from 'reselect';
// only care about height, lat & lng
export const FlightPlanSelector = createSelectorCreator(
defaultMemoize as any,
(a: FlightPlanPoint, b: FlightPlanPoint) => a.height === b.height && a.lat === b.lat && a.lng === b.lng
);
// use the new defined selector FlightPlanSelector
export const selectNotamTrajectoryPoints = FlightPlanSelector(
selectMapValueFP('flightPlan'),
(flightPlan) => flightPlan.map(fp => ({
height: fp.height || 150,
latitude: fp.lat,
longitude: fp.lng
}))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment