Created
November 19, 2019 14:29
-
-
Save ylastapis/14547ff897728852c5e5f3adb3dc8267 to your computer and use it in GitHub Desktop.
Change default memoize function of createSelector in reselect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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