RxJava2: parallel(): Want to know if at least one rail completes (conversion to Maybe)

27 views
Skip to first unread message

Johannes Schneider

unread,
Jan 15, 2019, 10:58:13 AM1/15/19
to RxJava
Hi guys,

I want to download a file from several possible locations. Each location has three possible results:
- error (e.g. a timeout, 404)
- success with a new file (200)
- not modified (304)


My (pseudo) code so far:

Flowable.just(url1, url2...)
.parallel()
.runOn(Schedulers.computation())
.map( ...http download ) 
.filter( ... status code == 200 )
.map( ... parse content ...)
.reduce( ..find newest file..)


My problem: I can not differentiate between errors and not modified.


What I would like as result:

A Maybe<File> that gives me the following calls:
- onError: if *all* urls have failed
- onNext: if at least one url has returned 200
- onComplete: if at least one url has *not* returned an error


Is this possible?

Thanks,

Johannes



Reply all
Reply to author
Forward
0 new messages