I am writing some repository logic for android application, I have this logic for retrieving data from database and updating the database with data from api immediately after that.
fun fetchData(): Single<Data> {
return Single.concatArrayEager(
fetchFromDb(),
fetchFromApi())
.firstOrError()
}
By the way - database is Room and api is Retrofit. Now what happens is that room emits almost instantly, but for some reason api request is not fired - the second Single
doesn't start.
I read the documentation on the eager operator and I am not sure if this is correct behavior. I even tried to delay the database fetch, by like 20 miliseconds - which resulted in that second single being actually fired