I have a RxJava's chain that looks like this:
Completable.complete()
.andThen(fetchData())
.andThen(fetchAnotherData())
.andThen(...)
.doOnSubscribe {
/* some action */
}
The problem is that code in doOnSubscribe callback called after last andThen(). But I want it to be called before fetching any data. How do I achieve it?
Try defer
the subscription of fetchData()
Completable
Completable.complete()
.andThen(Completable.defer { fetchData() })
.andThen(Completable.defer { fetchAnotherData() })
.doOnSubscribe { /* some action */ }