RxJava: difference between doOnNext and doOnEach

后端 未结 1 1865
[愿得一人]
[愿得一人] 2020-12-29 18:24

In which cases I should use doOnNext, and in which cases doOnEach?

 .doOnEach(new Action1>() {
                      


        
相关标签:
1条回答
  • 2020-12-29 18:58

    They are indeed quite close. One thing that differs (and it's maybe not that clear in the javadoc actually, more visible in sourcecode) is that in doOnEach, you also get Notification wrappers for errors and completion event.

    You can then check isOnNext, isOnCompleted or isOnError to check the actual kind of event you got a notification for.

    So one Action.call to rule them all, instead of a fully fledged Observer

    0 讨论(0)
提交回复
热议问题