Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel all Retrofit requests at once?

I know that individual Retrofit requests can be cancelled at any time by simply calling retrofitCall.cancel();

But I need a way to cancel all ongoing requests at once. Is it possible? I haven't found anything like it in the documentation.

like image 871
Guy Avatar asked Jun 07 '16 13:06

Guy


1 Answers

You have to keep reference to your shared OkHttpClient.

Than when you want to cancel all requests just call:

client.dispatcher().cancelAll()
like image 124
Viktor K Avatar answered Oct 13 '22 12:10

Viktor K