https://kotlinlang.org logo
Title
a

Abhishek Dewan

03/06/2021, 7:19 AM
Hi I am not sure what I am doing wrong here. In my app I have an authenticationRepo that has two suspend methods. I am aware that using global scope is not the right way to start a coroutine but this is for testing purposes. The problem I am seeing is that after collecting the flow from the first call to authenticationRepo, I don’t see to be able to get the second call to authenticationRepo to fire (as can be seen from the recording). I am not sure if i am using flows incorrectly but I am unable to understand why is the second line of code not hitting
Does collecting the flow cancel the coroutine scope ?
m

Mustafa Ozhan

03/06/2021, 9:35 AM
nope it is still waiting for the
collect
You need to create a new
GlobalScope.launch
for the second one if you want them to run parallel
l

louiscad

03/06/2021, 9:56 AM
Just
launch
on the right scope, not
GlobalScope
.
There's also
flow.launchIn(scope)