https://kotlinlang.org logo
#coroutines
Title
# coroutines
t

Tuan Kiet

09/17/2019, 8:08 AM
does kotlin coroutine suit for fire and forget scenario, for example, I want to fire 1000 network request in 5 minutes, something like
viewModelScope.launch{}
but don’t care about the result. When a coroutine is finished, does it goes away or it stays in memory?
d

Dominaezzz

09/17/2019, 11:07 AM
It goes away.
a

ahulyk

09/17/2019, 1:03 PM
viewModelScope is not good for that - it could be canceled
g

gildor

09/17/2019, 2:27 PM
Depends on required lifecycle of those requests. Launch and forget doesn't mean that request doesn't have lifecycle and may be cancelled
t

Tuan Kiet

09/17/2019, 11:23 PM
It has the lifecycle equal to Application’s lifecycle. And I will create my own coroutine scope for that
g

gildor

09/17/2019, 11:24 PM
GlobalScope is also fine for this
Tho, we have UserScope which cancelled if app user is unauthorized
12 Views