[英]Canceling multiple subscriptions at once in RxAndroid - Android
I use Retrofit with RxAndroid to handle couple of requests in one Activity, 我使用Retrofit和RxAndroid来处理一个Activity中的几个请求,
So I have couple subscription variables in the activity as public, 所以我在活动中有几个订阅变量为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). 现在在活动的
onStop
我想取消它们(如果它们没有完成)。
Is there any way that we can cancel or unsubscribe all of them at once ? 有什么方法可以一次取消或取消订阅所有这些内容吗?
您可以将它们添加到CompositeSubscription中并在onStop
取消订阅。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.