oscarg798
07/02/2020, 3:06 PMval flow1 = flow<Int> {
emit(1)
}
val flow2 = flow<Int> {
throw IOException()
}
merge(flow1, flow2).onEach {
print(it.toString() + "\n")
}.catch {
emit(3)
}.launchIn(CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>))
Do I have to catch the flows before merging them or there is something wrong in the example ?Zach Klippenstein (he/him) [MOD]
07/02/2020, 4:43 PMZach Klippenstein (he/him) [MOD]
07/02/2020, 4:44 PMoscarg798
07/02/2020, 9:23 PMZach Klippenstein (he/him) [MOD]
07/07/2020, 8:54 PMmerge
operator will forward items from all its inputs, but if one of them fails, it has to propagate that error downstream. And the Flow contract says that once a stream has failed (the collector receives an exception), then it can’t emit any more. So if the merge operator propagates the error downstream, that means the downstream has to be considered failed, and can’t emit anything else.