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 |