Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] - To cancel all the call requests without tracking all in-flight requests and can achieve as volley to set a tag and cancel all requests with the tag. #2608

Closed
rodent129 opened this issue Jan 9, 2018 · 1 comment

Comments

@rodent129
Copy link

rodent129 commented Jan 9, 2018

To cancel retrofit call request, we need to call call.cancel().
But if we have many simultaneous calls request in the background and want to cancel all of them, then we have to track not finishing call requests and calling one by one.

But in volley, you can then use the tag to provide a scope of requests to cancel. For example, you can tag all of your requests with the Activity they are being made on behalf of, and call requestQueue.cancelAll(this) from onStop(). Similarly, you could tag all thumbnail image requests in a ViewPager tab with their respective tabs and cancel on swipe to make sure that the new tab isn't being held up by requests from another one.

Is that possible to do in retrofit 2.0 or is it possible to add a new feature?

Thanks a lot.

@JakeWharton
Copy link
Member

Dupe of #2394. There is not access to OkHttp's tag currently. You might be able to add dummy headers and loop through OkHttp's in-flight Calls and match on them that way though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants