Slide 15
Slide 15 text
SUSPEND COROUTINE
suspendCoroutine { cont: Continuation ->
doLongTask { result, exception ->
if (exception == null)
cont.resume(result)
else
cont.resumeWithException(exception)
}
}
fun doLongTask(cb: (T, Throwable) -> Unit) {
}
suspend fun suspendCoroutine(
block: (Continuation) -> Unit
): T