Hey all, in RxJava, we have `doOnNext` operators f...
# coroutines
s
Hey all, in RxJava, we have 
doOnNext
 operators for side-effects, like printing, etc. What is the equivalent in Kotlin Flows? AFAIK, 
onEach
 consumes the flow, and would not be appropriate there. Or am I missing something?
w
onEach
doesn’t consume the flow and afaik is pretty much replacement for
doOnNext
👍 1
s
Well consumes might be not the correct term, but it can alter the flow, with things like
delay(..)
, etc., while RxJava's
doOnNext
does not
e
doOnNext { Thread.sleep(100) }
alters it in a similar way. No difference.
👍 1
If you do something heavy or taking long time in either of them, you'll alter the stream. If you do something quick, then you don't
s
🤔 well that makes sense
So
onEach
is the way. Thanks @elizarov, Pleasure to get an answer from the founder imself!
and also thankx @wasyl
👍 1