I'm in the middle of migrating Rxjava based project to Coroutine Flow. I need to merge multiple api calls and if one of them fails, I still want it to proceed and do the job. Here's the original code.
fun requestHomeDataAtOnce() {
val requestList = mutableListOf(
requestTab1(),
requestTab2(),
requestTab3(),
requestTab4()
)
requestHome(requestList = requestList)
}
private fun requestHome(requestList: MutableList<Single<out Result<Any>>>) {
val responseList: MutableList<Any?> = mutableListOf()
Single.mergeDelayError<Any>(requestList)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread(), true)
.subscribe({
//.. do something
})
//..
}
So I noticed that mergeDelayError will run merged sources and delay any error.
My question is, should I use Flow combine or flattenMerge in this case?
I'm still trying to grasp the basic concept of it.