Using Rx one can merge multiple subscription sources like the following
// psudo data repository
fun getAllData(): Flowable<DataType> {
return getCachedData().mergeWith(getRemoteData())
}
fun getCachedData(): Flowable<DataType> {
// local database call
}
fun getRemoteData(): Flowable<DataType> {
// network call
}
in the code above getAllData() will return data as soon as one of the merged Flowables returns and then send the other once it's ready.
Question is, How can I achieve the same result using Kotlin coroutine's produce?