CLOVIS
10/14/2020, 5:40 PMval input: Flow<MyObject> = ...
val output = input.map { it.toOtherObject() }
I would like the calls to toOtherObject
to be ran in parallel, and I would like an exception in one call not to stop the others.
I tried:
val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
val output = input.map {
scope.async {
it.toOtherObject()
}
}.map { it.await() }
But this is still sequential, and not parallel. What am I doing wrong?Luis Munoz
10/14/2020, 5:47 PMCLOVIS
10/14/2020, 5:50 PMflatMapConcat
, and then `collect`ing the result.flatMapMerge
solves the concurrency issue, however it doesn't allow me to pass a SupervisorScope
taer
10/15/2020, 9:43 PMtoOtherObject
call? return null in the catch and later on mapNotNull?