forked from Blendman974/faceclaw
Kotlin on iOS
This commit is contained in:
1 parent
63b2a7d545
commit
bc8e80c533
12 files changed
+149
-57
No files matched your search
@@ -1,21 +0,0 @@
|
||||
package com.faceclaw.shared
|
||||
|
||||
/** NativeScript implements this Kotlin-owned contract in TypeScript. */
|
||||
interface KotlinBridgeListener {
|
||||
fun transform(message: String): String
|
||||
}
|
||||
|
||||
/**
|
||||
* First step toward commonMain: only portable Kotlin, with no Android/JVM APIs.
|
||||
* Calls and callbacks are synchronous on the caller's thread. The listener is
|
||||
* used only during roundTrip and is never retained.
|
||||
*/
|
||||
class KotlinBridge {
|
||||
fun greet(name: String): String = "Hello, $name, from Kotlin"
|
||||
|
||||
fun roundTrip(message: String, listener: KotlinBridgeListener): String {
|
||||
val reply = listener.transform("Kotlin received: $message")
|
||||
// Consume the TypeScript return value, then return it across the bridge.
|
||||
return "Kotlin received callback: $reply"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user