Sam
02/15/2019, 10:00 PMzak.taccardi
02/15/2019, 10:12 PMSam
02/15/2019, 10:13 PMpublic fun invokeOnCompletion(handler: CompletionHandler): DisposableHandle
bdawg.io
02/15/2019, 10:19 PMSam
02/15/2019, 10:20 PMbdawg.io
02/15/2019, 10:26 PMsuspend fun main() = coroutineScope<Unit> {
val job = launch { delay(1000) }
job.invokeOnCompletion { println("handler one called") }
job.invokeOnCompletion { println("handler two called") }
job.invokeOnCompletion { println("handler three called") }
}
prints out handler one called
handler two called
handler three called
Sam
02/15/2019, 10:30 PMbdawg.io
02/15/2019, 10:31 PMInstalled [handler] should not throw any exceptions. If it does, they will get caught, wrapped into [CompletionHandlerException], and rethrown, potentially causing crash of unrelated code.
Sam
02/15/2019, 10:32 PM