Sam
07/23/2021, 5:05 PMprivate var job: Job? = null
private fun scheduleJob() {
job?.cancel()
job = flow<Void> {
delay(mySpecifiDelay)
doWork()
}.launchIn(CoroutineScope(coroutineDispatcher))
}Dominaezzz
07/23/2021, 5:07 PMGlobalScope there.Dominaezzz
07/23/2021, 5:08 PMlaunch .Dominaezzz
07/23/2021, 5:09 PMGlobalScope , just store your CoroutineScope somewhere and re-use it.Sam
07/23/2021, 5:09 PMprivate fun scheduleJob() {
job?.cancel()
job = CoroutineScope(coroutineDispatcher).launch {
delay(mySpecifiDelay)
doWork()
}
}Sam
07/23/2021, 5:10 PMDominaezzz
07/23/2021, 5:12 PMGlobalScope . It's the same thing but less allocations.andylamax
07/25/2021, 10:44 AM