Overview

Summary
Kotlin compiler plugin for generating platform-compatible functions for suspend functions.
Quick Example
JVM Platform
class Foo {
@JvmBlocking
@JvmAsync
suspend fun waitAndGet(): String {
delay(5)
return "Hello"
}
}
The plugin automatically generates:
class Foo {
@JvmSynthetic
suspend fun waitAndGet(): String {
delay(5)
return "Hello"
}
@Api4J
fun waitAndGetBlocking(): String = runInBlocking { waitAndGet() }
@Api4J
fun waitAndGetAsync(): CompletableFuture<out String> = runInAsync { waitAndGet() }
}
JavaScript Platform
class Foo {
@JsPromise
suspend fun waitAndGet(): String {
delay(5)
return "Hello"
}
}
The plugin automatically generates:
class Foo {
suspend fun waitAndGet(): String {
delay(5)
return "Hello"
}
@Api4Js
fun waitAndGetAsync(): Promise<String> = runInAsync { waitAndGet() }
}
Platform Support Status
Platform | Since Version |
---|---|
JVM | 0.1.0 |
JavaScript | 0.6.0 |
WasmJS (Experimental) | 0.6.0 |