Debugging RxJava zip statement that stops

Writing in Java I call the zip () method, which receives several methods that return Observable <...>.

I am currently unable to navigate to the next map, and this is probably because one of the methods has not returned a value yet. (Though it seems like all the methods are called.)

Is there a way to debug the process and see why it gets stuck?
Thank.

+3


source to share


1 answer


Suppose you have:

result = Observable.zip(sourceA, sourceB, sourceC)

      

Just add .doOnNext()

for each of the sources to log what they emit (or instead doOnNext

, subscribe to each). For example:



result = Observable.zip(sourceA.doOnNext(/*logging...*/),
                        sourceB.doOnNext(/*logging...*/),
                        sourceC.doOnNext(/*logging...*/))

      

What is likely happening is that one of these sources does not emit at the same frequency as the others. zip

should be used when you are strictly aware that all sources emit events at the same rate / frequency. You can try using combineLatest

. The difference between them:

  • zip: The returned Observable emits the nth combination element only when all nth source elements are counted. See the diagram.
  • combLatest: The returned Observable emits a "combination" element when any of its sources emits an element. See the diagram.
+5


source







All Articles