mapbox-navigation-android icon indicating copy to clipboard operation
mapbox-navigation-android copied to clipboard

Directions API requests should be canceled when NavigationActivity is destroyed

Open cammace opened this issue 9 years ago • 5 comments

It's good practice to cancel any calls that Retrofits making if the activity gets destroyed. We can make use of the Lifecycle component

screen shot 2017-10-23 at 4 16 31 pm to automatically cancel the event.

@zugaldia @danesfeder

cammace avatar Oct 23 '17 20:10 cammace

Architecture components and Retrofit is explicitly mentioned on the official docs: https://developer.android.com/topic/libraries/architecture/guide.html#fetching_data

zugaldia avatar Oct 24 '17 16:10 zugaldia

@danesfeder, I remember a few weeks ago you asked about canceling the request? Did this issue get worked out?

cammace avatar Jan 22 '18 02:01 cammace

@cammace I didn't have a chance to add this to NavigationRoute but should be a quick PR to expose that API

danesfeder avatar Jan 22 '18 14:01 danesfeder

@cammace @danesfeder Assuming you are talking about having NavigationRoute implement LifecycleObserver, how were you invisioning setting it up with a LifecycleOwner? Passing the LifecycleOwner to the NavigationRoute, or manually setting it everywhere NavigationRoute is used? It's a little complicated in the case of RouteEngine because NavigationRoute is a couple steps removed from any LifecycleOwners.

devotaaabel avatar Mar 25 '18 20:03 devotaaabel

@danesfeder & @akitchen were discussing -- it would also be good to provide developers with a way to cancel outstanding requests from NavigationRoute

akitchen avatar Mar 26 '18 20:03 akitchen