Is there a reason why a coroutine lambda wouldn't be executed after launch is called on it? I have a KMP project and on iOS, the launch function is called, but the lambda isn't executed. I'm pulling at threads trying to figure out why this isn't working. I don't have any errors in my project when ran.
j
Joffrey
06/06/2022, 9:44 PM
What dispatcher are you launching the coroutine in? It might be due to thread starvation
t
Trey
06/06/2022, 9:46 PM
The viewModel just instantiates the scope using:
Copy code
val viewModelScope = MainScope()
I noticed just noticed that calling viewModelScope.isActive before I call launch returns false.
j
Joffrey
06/06/2022, 9:48 PM
Do you have a small reproducible example you could share?
t
Trey
06/06/2022, 9:49 PM
I think I see my problem. I believe that the viewModel is getting cleared before my call. That cancels the main scope.
👍 1
j
Joffrey
06/06/2022, 9:50 PM
That would indeed explain what you see, and be expected behavior