rnett
06/02/2021, 9:42 AMexpect object
(MyKrosstalk
), declaring a RPC method is as simple as:
// common
@KrosstalkMethod(MyKrosstalk::class)
expect suspend fun basicTest(n: Int): List<String>
// client (i.e. js)
actual suspend fun basicTest(n: Int): List<String> = krosstalkCall()
// server (i.e. jvm)
actual suspend fun basicTest(n: Int): List<String> = List(n) { "$it" }
See the README for the full example, and details.
https://github.com/rnett/krosstalkPiotr Krzemiński
06/02/2021, 9:55 AMBig Chungus
06/02/2021, 9:58 AMNikky
06/02/2021, 10:08 AMplugins {
id("com.github.rnett.krosstalk")
}
christophsturm
06/02/2021, 10:10 AMBig Chungus
06/02/2021, 2:51 PMrnett
06/02/2021, 9:07 PMPOST krosstalk/myMethod_12f45
, so if you actually want to call them externally use @KrosstalkEndpoint
.rnett
06/02/2021, 9:08 PMGradle plugin (required)
in the readme. I should probably make it a bit more obvious.rnett
06/02/2021, 9:10 PM@KrosstalkMethod
, and on the client side, replaces krosstalkCall()
with something like MyKrosstalk.call(mapOf("n" to n))
(for the example)Big Chungus
06/02/2021, 9:23 PMrnett
06/02/2021, 9:27 PMrnett
06/02/2021, 9:33 PMrnett
06/02/2021, 9:34 PM