When should we use doOnNext() from Observable instead of just onNext()?
Advertisement
Answer
doOnNext
is for side-effects: you want to react (eg. log) to item emissions in an intermediate step of your stream, for example before the stream is filtered, for transverse behavior like logging, but you still want the value to propagate down the stream.
onNext
is more final, it consumes the value.