Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canceling multiple subscriptions at once in RxAndroid - Android

I use Retrofit with RxAndroid to handle couple of requests in one Activity,

So I have couple subscription variables in the activity as public,

public Subscription sub1;
public Subscription sub2;
public Subscription sub3;
public Subscription sub4;
public Subscription sub5;

now in the onStop of the activity I want to cancel them all (if they did not finish).

Is there any way that we can cancel or unsubscribe all of them at once ?

like image 405
MBH Avatar asked May 16 '26 23:05

MBH


1 Answers

You can add them into a CompositeSubscription and unsubscribe it in onStop.

like image 129
zsxwing Avatar answered May 18 '26 20:05

zsxwing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!