Mendess
05/19/2022, 9:16 PMMendess
05/19/2022, 9:22 PM// this class is implemented on the js side
@JsExport
abstract class Adapter {
@JsName("method")
abstract fun method(params...., callback: (Foo) -> Unit)
}
internal class InternalService(private val adapter: Adapter) {
suspend fun method(params...): Foo {
suspendCoroutine { cont -> adapter.method(params) { cont.resume(it) } }
}
}
ts-land
class WebAdapter extends Adapter {
override method(params..., callback: (f: Foo) -> Unit) {
callback(makeAFoo())
}
}
and the generated javascript calls a mangled method on that adapter inside the InternalService
, something like this.adapter_1.method_36nz9g_k
rnett
05/19/2022, 10:50 PMMendess
05/20/2022, 10:55 AM