3

I am using RxJava CombineLatest with two observables. My question is, will the combine onNext called if one of the observables ends with onError?

The documentation shows happy scenario when both observables emits items properly but I couldn't find what will happens on error case.

|----onError ----| Observable1

|----------- O ------- O ------| Observable2

|--------------?----------?----| CombineLatest - will onNext will be called?

Moti Bartov
  • 3,454
  • 33
  • 42

1 Answers1

3

The general contract is this: the coordinating operators terminate upon receiving the first onError from any of their sources, unless there is a delayErrors parameter set to true or the operator name has DelayError postfix.

There is an additional rule for combineLatest regarding short-circuiting due to empty sources:

If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

akarnokd
  • 69,132
  • 14
  • 157
  • 192
  • Thanks for this answer, however, I've found some solution for this by using onErrorReturn which allows a source to return some default value in case of an error. This will keep the sequence alive in case of one source had an error. – Moti Bartov Feb 25 '19 at 10:47