Does it matter if I use GlobalScope for application-level coroutines in KMM?

Viewed 254

I have an ViewModel Kotlin class in a single-Activity Android app that starts coroutines that talk to an application-level repository.

In Android I use the ViewModel scope with Dispatchers.IO to start the coroutines.

viewModelScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT, someFunction)

In iOS I can't use viewModelScope, but I still create my "ViewModel"s at the application-level in my iOS project. So I use GlobalScope with Dispatchers.Default (being as Dispatchers.IO doesn't exist in iOS projects).

GlobalScope.launch(Dispatchers.Default) {
  someFunction()
}

I understand that GlobalScope is now marked as delicate, and it doesn't conform to Kotlin's structured concurrency. So instead I used

MainScope().launch(Dispatchers.Default) {
 someFunction()
}

But I'm wonder if, for my case, since my coroutines are application-level, it doesn't actually matter if I use GlobalScope? I can't see any downsides, but maybe there are some. Any input would be appreciated.

(I'm using the experimental memory model for KMM, in case this matters)

0 Answers
Related