Move Kotlin shared code

This commit is contained in:
James Babcock committed 2026-09-18 20:43:24 -07:00
1 parent 1e1c3f799d
commit c0f8f7e9c2
2 files changed
+19 -1

No files matched your search

@@ -0,0 +1,21 @@
package com.faceclaw.shared
/** NativeScript implements this Kotlin-owned contract in TypeScript. */
interface KotlinBridgeListener {
fun transform(message: String): String
}
/**
* Portable Kotlin at the same commonMain source path used by ios-port.
* 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"
}
}