vertx-lang-kotlin
vertx-lang-kotlin copied to clipboard
Investigate usefulness of code generation for Kotlin coroutines
for instance, now we use the await*
suspending function like this
val id = awaitEvent<Long> { vertx.setTimer(1000, it) }
we could generate extensions:
suspend fun Vertx.setTimer(delay: Long): Long {
return awaitEvent<Long> { setTimer(delay, it) }
}
that allow to directly write:
val id = vertx.setTimer(1000)
LGTM :) by the way, the last line is
val id = Vertx.setTimer(1000)
actually no, this is Kotlin and that's an extension method that is available on vertx instances.
It's true, my fault. 😅
This would be very preferential. There are many areas that callbacks in vertx api could be translated to coroutine suspension function and IMO would make it more idiomatic kotlin and simpler for those approaching vertx as well.
It is useful if working with coroutine. Is this code generator done by vertx-codegen?
@feiyanke yes, it is currently implemented for data object and Kotlin in this project
I have spent the long weekend to come up with this pull request #53 . The code is quite hacky for now though. 😕
Would anyone mind reviewing before I continue?
Closing as outdated, coroutines support has been implemented