RX Java – cancel observable in rxjava

I have an observable object that is performing a download However, when I click the button, I want to cancel the observation

How is that possible?

thank you.

Solution

You can't really tell observable to cancel the network request because RX Java doesn't know the code running in observable What you can do is use doonunsubscribe to check whether the network request is still running. If it is cancelled, just cancel the subscription

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>