I am using RxJava combineLatest operator.
According to the documentation, when subscribing, the first combine emit event will occur only after both observables emits there values, and from this point, it will emit on every emit of each of the Observables.
How can I determine that the first observable emit event has been occurred and it now waits for the second one..
You can use doOnEach
for Observables
and Flowables
or doOnEvent
for Singles
, Completables
and Maybes
. What those operations do is execute some code each time an item is emitted from the source before passing the signal down stream. It's very useful for "injecting" debug/logging code into an RX stream.
See: https://proandroiddev.com/briefly-about-rxjava-logging-20308b013e6d
EDIT:
val a = BehaviorSubject.create<Int>().apply {
onNext(1)
}.doOnEach { EventReporter.d(TAG, it.value?.toString() ?: "") }
val b = BehaviorSubject.create<Int>().apply {
onNext(2)
}.doOnEach { EventReporter.d(TAG, it.value?.toString() ?: "") }
Observable.combineLatest(listOf(a, b), { args: Collection<Int> -> args}