I have an observable that is performing a download. However I want to cancel that observable when I click on a button.
How is that possible?
Thank you.
You can't really tell an observable to cancel a network request as RxJava has no knowledge of the code thats running inside of the Observable. What you can do is use the doOnUnsubscribe
to check whether the network request is still running and if it is cancel it, then just unsubscribe when you want to cancel.