Search code examples
androidrx-java

Rxjava newbee question around chosing an observable


Have a problem that I cant seem to figure out a good solution for. I have 2 observables that I am trying observe on. During a session only 1 will spit out information while the other will throw an exception when I observe it. The data they return is the same. Is there a simple way for me to observe both the observables and not have to wrap the exception?

observeA = Observable A
observeB = Observable B

Observable.<>(observeA, observeB).subscribeOn(blah)

Thanks!


Solution

  • If you don't care about the exception at all, you can use merge to observe both and onErrorComplete each to ignore the error:

    observeA = Observable A
    observeB = Observable B
    
    Observable.merge(
        observeA.onErrorComplete(), 
        observeB.onErrorComplete()
    ).subscribeOn(blah)