vertx / io.vertx.kotlin.coroutines / awaitEvent

# awaitEvent

`suspend fun <T> awaitEvent(block: (h: Handler<T>) -> Unit): T`

Run an asynchronous block and awaits the completion.

The block is executed with a `Handler<T>` argument that shall be called once.

When the handler is called, `awaitEvent` returns the value that the handler received.

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

    val s = awaitEvent { handler ->
      server.setTimer(1000, handler)
    }

The coroutine will be blocked until the event occurs, this action do not block vertx's eventLoop.

### Parameters

`block` - the code to run