dharrigan
10/04/2019, 8:36 AMfun updateDetails() = GlobalScope.launch(<http://Dispatchers.IO|Dispatchers.IO>) {
// loop forever
updateDetailsAsync()
// wait until updateDetailsAsync is done
}
fun CoroutineScope.updateDetailsAsync() {
does an REST API lookup
writes into a database
}
spand
10/04/2019, 8:50 AMwhile (true)
loop cut it?dharrigan
10/04/2019, 8:52 AMspand
10/04/2019, 8:56 AMdharrigan
10/04/2019, 8:56 AMdo {
updateDetailsAsync()
delay(MINUTES.toMillis(1))
} while (true)
CoroutineScope.updateDetailsAsync()
to return a Job, then join on the jobspand
10/04/2019, 8:59 AMsuspend
?dharrigan
10/04/2019, 8:59 AMDominaezzz
10/04/2019, 10:26 AMwhile(isActive)
is a bit better.spand
10/04/2019, 10:44 AMDominaezzz
10/04/2019, 10:47 AMspand
10/04/2019, 10:53 AMsuspend
function no ?Dominaezzz
10/04/2019, 11:02 AMdharrigan
10/05/2019, 12:39 PM