Nicolas Verinaud
09/02/2022, 10:08 AMclass Sample(private val scope: CoroutineScope) {
private var currentJob: Job? = null
fun doSomeAsyncWork() {
currentJob?.cancel() // how to test this line ?
currentJob = scope.launch {
delay(5000)
}
}
}
mkrussel
09/02/2022, 12:30 PMdoSomeAsyncWork
twice and see that the first job was canceled and the second job was started.Robert Williams
09/02/2022, 12:48 PMRobert Williams
09/02/2022, 12:48 PMdoSomeAsyncWork
is creating the job at all is an implementation detailRobert Williams
09/02/2022, 12:49 PMNicolas Verinaud
09/02/2022, 2:49 PMNicolas Verinaud
09/02/2022, 2:50 PM