I would like to merge two Single<MyData>
such that if one of them fails but the other one succeeds then the error of the one that failed and the emission from the other one are reported, and then the resulting Single<MyData>
(or Observable<MyData>
) completes.
If both Single<MyData>
fail then the result should also fail and also be marked as failed.
What I would like to have at the end is:
It's like an 'OR' operation
This is not possible. There is only a single terminal event allowed. The contract for Single
is success|error
. If you need to receive a next event as well, you should consider to use Observable
instead. The contract for Observable
is next* complete|error
, but you'll still not get a complete.
Observable.mergeDelayError(single1.toObservable(), single2.toObservable())