samuel
11/24/2020, 4:53 PM// Run multiple async tasks and combine them and enit as one flow
val finalFlow: Flow<SomeType> = flow{
supervisorScope {
val firstAsyncAction = async { firstAsyncActionFlow }
val secondAsyncAction = async { secondAsyncActionFlow }
val thirdAsyncAction = async { thirdAsyncActionFlow }
emitAll(
awaitAll(
firstAsyncAction,
secondAsyncAction,
thirdAsyncAction
).merge()
)
}
}
finalFlow.collect {
// This runs multiple times discarding the previously sent items from the flow
}
However, this emits as soon as any of the async tasks complete which is not the desired result. How would i handle such a use case?