vertx / io.vertx.kotlin.coroutines / awaitResult

awaitResult

suspend fun <T> awaitResult(block: (h: Handler<AsyncResult<T>>) -> Unit): T

Run an asynchronous block and awaits the result.

The block is executed with a Handler<AsyncResult<T>> argument that can be completed or failed.

This handler can be passed to Vert.x asynchronous method:

val s = awaitResult { handler ->
  server.listen(8080, handler)
}

The coroutine will be blocked until the future is completed or failed, this action do not block vertx's eventLoop.

Parameters

block - the code to run