do other work val image = deferred.await() showImage(image) } Suspension might not happen if the result is already available processImage loadImageAsync await 1 2 processImage loadImageAsync
{ val first = loadImageAsync("green") val second = loadImageAsync("red") overlay(first.await(), second.await()) } Image overlay: two asynchronous computations
foo() } fun fooAsync(): Single<Int> = rxSingle(CommonPool) { foo() } To call suspend foo from Java wrap it into fooAsync if you have Java 8 if you have RxJava
val seq = buildSequence { yield(load("first")) yield(load("second")) } for (s in seq) { println("processing $s") } loading first processing first loading second processing second yield when required