Reputation: 3753
I'm fairly new to rxjava, so apologies if this is a silly question. I have two Maybes (call them A and B) that I want to compose in such a way that I get a 3rd Maybe.
If A succeeds, I want my composite to succeed with that same value. If A errors, I want my composite to error with that same throwable. If A completes without emitting a value, I want to then delegate to B.
Is there an easy way to achieve this?
Upvotes: 4
Views: 541
Reputation: 16142
If you don't care about specific errors in A, you can use the following:
A
.onErrorResumeNext(Observable.empty())
.switchIfEmpty(B)
Upvotes: 4