dvsakgec :
I have this confusion, when does doOnNext is triggered before or after of element emission by Publisher (Flux/Mono).
Michael Berry :
It's after the publication of the element - and it has to be after by definition, otherwise the Consumer
passed to doOnNext
wouldn't have access to the element emitted.
However, doOnNext()
is called before the subscriber. For example:
Flux.just("first", "second")
.doOnNext(x -> System.out.println(x + " onNext"))
.subscribe(System.out::println);
...would output:
first onNext
first
second onNext
second