bramus / react-native-maps-directions

Directions Component for `react-native-maps`
MIT License
1.25k stars 198 forks source link

Add memoization option to avoid unnecessary requests #173

Open SchneiderOr opened 3 years ago

SchneiderOr commented 3 years ago

What changed?

I've added another prop that the component can take called isMemoized, by default requests are not memoized, but if you pass either boolean or a callback function you can decide when you want to memoize the request, if you pass only true to the isMemoized, memoization will be by the callee arguments (origin, destination, region, etc)

This memoize reduce a lot of unnecessary requests and preserve quota

Also in this PR - format the files with formatter rather then keeping them in an inconsistent styling

LazyAfternoons commented 2 years ago

@bramus any news for this PR? Looks like something really useful to preserve quota when origin and destination do not change between renders. Thank you for your work.

SchneiderOr commented 2 years ago

Im working with this code on my project for few months now and it works very well, Im waiting on project maintainer to decide if he want to merge it down or not