2 ms·
Can someone explain why this: geolocator.getLatLng("Forest Park, St. Louis, MO", displayMapAt); Is better than this? displayMapAt(geolocator.getLatLng("F
by scott_s 17y ago
Can someone explain why this:
geolocator.getLatLng("Forest Park, St. Louis, MO", displayMapAt);
Is better than this?
displayMapAt(geolocator.getLatLng("Forest Park, St. Louis, MO"));
That is, why is it more sensible for getLatLng to accept a callback function that will accept its result, when one can just pass its result to a function?
- abecedarius 17y agoI expect the call to geolocator requires a network round-trip, with displayMapAt getting scheduled to be called when the result appears; meanwhile your code can do other things. (I'm not familiar with this API, though; I could be wrong.) Another way to do this sort of thing, that might feel more composable: have geolocator.getLatLng() return a 'promise' object that will be asynchronously resolved.
- deleted 17y ago[deleted]