As we are coming closer to release we'll need to f...
# coroutines
e
As we are coming closer to release we'll need to finalize/cleanup APIs of
kotlinx.coroutines
, even though they are experimental. Let me float an idea. The functionality of
defer {...} .await()
is very similar to C#/JS/Dart `async`/`await` pair. The key difference is that in C# it returns
Task
, in JS it returns
Promise
, in Dart it returns
Future
, and in Kotlin it returns
Deferred
. So, the idea is to rename
defer
to
async
to fall in line with everybody else on this one aspect. Naming it
async
also makes writing async-style functions somewhat more natural:
Copy code
// runs the code in the background thread pool
fun asyncOverlay() = async(CommonPool) {
    // start two async operations
    val original = asyncLoadImage("original")
    val overlay = asyncLoadImage("overlay")
    // and then apply overlay to both results
    applyOverlay(original.await(), overlay.await())
}
What do you think? Shall we name it
async
?
👍 4