I am downloading some files from the network using retrofit and rxjava. In my app, the user may cancel the download.
Pseudo Code:
Subscription subscription = Observable.from(urls)
.concatMap(this::downloadFile)
.subscribe(file -> addFileToUI(file), Throwable::printStackTrace);
Now, If I unsubscribe this subscription, then all requests get canceled. I want to download one by one, that's why used concatMap. How do I cancel particular request?