vertx-lang-kotlin icon indicating copy to clipboard operation
vertx-lang-kotlin copied to clipboard

Closure interoperability with Handler

Open aesteve opened this issue 7 years ago • 1 comments

Hello,

I'm often finding myself stuck with this kind of stuff :

    @Before
    fun setup(ctx: TestContext) {
        vertx.executeBlocking<Void>( { fut: Future<Void> ->
            // blocking stuff
            fut.complete()
        }, ctx.asyncAssertSuccess())
    }

This code doesn't compile because the first closure cannot be understood as a Handler<Future<Void>>

The compiling equivalent would be :

    @Before
    fun setup(ctx: TestContext) {
        vertx.executeBlocking<Void>( Handler { fut: Future<Void> ->
            // blocking stuff
            fut.complete()
        }, ctx.asyncAssertSuccess())
    }

Is there a way to avoid the Handler { stuff ? Is this a kotlin limitation ?

In every other language, scala included, a lambda is a valid replacement for a Handler can we do something about this ?

Thanks.

aesteve avatar Aug 10 '17 06:08 aesteve

is it still needed ? I've been able to write kotlin code without the need of an adapter.

vietj avatar Aug 17 '17 12:08 vietj

Closing as outdated, see https://github.com/vert-x3/vertx-lang-kotlin/blob/b725514a88210a7e274cb458cd23c6e87b82fecf/vertx-lang-kotlin-coroutines/src/main/java/io/vertx/kotlin/coroutines/VertxCoroutine.kt#L123-L127

tsegismont avatar Dec 08 '22 16:12 tsegismont