Robert Jaros
02/08/2024, 4:35 PMJsAny? With K/JS we can have a dynamic property which accepts any values, including functions (or lambdas). With K/Wasm we should use JsAny instead, but I don't see any way to assign a function to JsAny property.Svyatoslav Kuzmich [JB]
02/08/2024, 4:44 PMJsAny, for example:
external fun foo(x: (Int) -> Int)
Or you can convert function to JsAny by round-tripping it thought JS:
fun toJsAny(f: (Int) -> Int): JsAny = js("f")Svyatoslav Kuzmich [JB]
02/08/2024, 4:45 PMexternal or js() boundary.Robert Jaros
02/08/2024, 4:46 PMfun toJsAny(f: Function<*>): JsAny = js("f")Svyatoslav Kuzmich [JB]
02/08/2024, 4:47 PMRobert Jaros
02/08/2024, 5:01 PMRobert Jaros
02/08/2024, 5:40 PMtoJsAny(f :..) = js("f") conversion ... 🙂 What happened to my simple kotlin function? 🙂Robert Jaros
02/08/2024, 5:45 PMjs() just inlines some js code, but what it does with simple "f" ?!Svyatoslav Kuzmich [JB]
02/08/2024, 5:49 PMf is wrapped with a JS lambda when passed to JS. Similar thing happens to other supported types like Int and StringRobert Jaros
02/08/2024, 6:02 PMString objects are just copied between Wasm and JS memory... But my function is not copied - it is still able to access it's kotlin closure:
https://pl.kotl.in/jRPww3xmeSvyatoslav Kuzmich [JB]
02/08/2024, 6:10 PM