Abhishek Dewan
05/13/2021, 3:51 PMviewModelScope.launch {
flow1.collect {}
flow2.collect {}
}
Javier
05/13/2021, 3:53 PMJavier
05/13/2021, 3:54 PMCasey Brooks
05/13/2021, 3:54 PM.collect { }
is going to suspend until the flow completes, which may be never. Coroutines execute sequentially, so until flow1
completes, the launch { }
block will not be able to continue to flow2
.
The solution is to put each .collect { }
in their own launch block, so that they will both be running in parallelAbhishek Dewan
05/13/2021, 4:58 PMephemient
05/13/2021, 5:03 PM