These are chat archives for ReactiveX/RxJava

30th
Mar 2017
Shahar Yakir
@shaharyakir
Mar 30 2017 13:26

Hi, I'm building an app, in which I have a list of images, each is loaded asynchronously.
Each time an item in the list is required to display its content it makes a request like so (pseudo-code):

dataAccess.loadImage(url).subscribe(data => cell.imgData = data)

Now, a button which causes the list to refresh and load all its cells can be pressed numerous times by the user.

What happens now is that previous requests of the loadImage method are showing even if they do not belong to the current request.

I could assign a request id and verify upon the load request finish that the ids still match, but I'd really like to cancel the request if it's no longer needed, and also to find a more ReactiveX way of doing so.

My thinking is that I should be able somehow to build an observable stream that would include both the user initiated requests and the responses and to somehow zip them together, but I'm not sure how to approach that, since I'm opening a different sequence for each cell...

Mark Elston
@melston
Mar 30 2017 17:04
Or you could keep the subscription information and unsubscribe from the previous subscription when a new button press happens.