you cannot create a composable simply from javascr...
# compose-web
k
you cannot create a composable simply from javascript in Compose For Web, right? eg
Copy code
download("some_page/compose-app.js")
run("app.js")
h
What do you mean? Your compose web app is just a regular kotlin js project resulting in a normal js file you can fetch and run.
k
could such be used for a scriptable ui binding such as lua
h
If you are able to connect lua with js, sure.
k
would such benifit from recomposability ?
also how would the js for compose look like?
like is it possible to create and add compose ui directly from js
h
Could you please say, what you really try to archive? All the questions are somehow vague. I don't know how you want to execute lua in your browser and how to pass parameters from Lua to Kotlin. Compose is a Kotlin specifc compiler plugin for Kotlin code. You can use Compose Web to use declartive @Composable functions rendering UI in your browser written in Kotlin. Of course you can dynamically change the UI based on data.
k
alright
so either way we require kotlin to actually build the composable ui as declerative for both Android, Desktop, and Web
and sorry
h
It depends. First at all, Compose is a Kotlin compiler plugin to create a tree changing over time. If you want to use this tree to get UI, you use this tree to render your underlying UI, for example on web it is plain hmlt dom, and on android and desktop skia (a c grafic lib) is used. Of course, the wrapper needs to be written in Kotlin.
Or use the experimental ui implementations like compose web canvas using canvas or iOS using native UIKit (written in objective-c).
k
for example, creating the UI from JNI interop calls,
JNI <-> Java/Kotlin -> UI api
h
It really depends what you are passing over JNI. Of course you can pass data and create your views like you do with any other data source. If you want to call the composable functions directly from jni, don't do it.
k
eg
Copy code
void * text = CreateText("hello"); // creates text object on java/kotlin side
void * box = CreateBox(); // creates box object on java/kotlin side
AddComponent(box, text); // reparents [text] to [box] such that [box] contains 1 child: [text], on java/kotlin side
h
Compose is declarative based on data. Your code is imperative based on function calls. So no, calling compose functions from JNI does not work at all. You should pass the data you want to show over JNI.
k
alright