Hi, atm I am using kotlinx-html, and a virtual dom...
# kmdc
r
Hi, atm I am using kotlinx-html, and a virtual dom with that would be really helpful. So purely out of self interest I was wondering why you choose not to use that dsl for html (dom) generation but choose to create your own?
b
Mainly because kotlinx html is not available on wasm and i want kvdom to seamlessly support both, js and wasm
The idea is to allow the user to write their app in kotlin and get both, js and wasm versions for free
I'll swap out the dsl and kvdom-dom module with official jetbrains bindings as soon as they make them available for wasm
I guess i could write a module to convert your kotlinx html dom tree to kvdom tree on js platform
r
The wasm part is interesting, I thought it's not possible to interact with the dom from wasm?
b
It's not, I'm writing js bindings for that
r
Ok, so diffing is done in wasm and then the result is sent to the main js thread?
b
But from user's perspective you interact with dom through kotlin kvdom elements
Not quite. All update commands are sent to js
But the app lives in wasm
r
Nice approach, I'll have to dive into wasm a bit. See if adding a VDOMBuilder to kotlinx-html for a wasm target is doable.
b
I doubt it, since there's simply no kotlinx html on wasm
What's possible is a module that typealiases kotlinx html and implements it on wasm
But that's not a trivial task
r
Most of the kotlinx-html stuff is in common, isn't that accessible from the wasm target?
b
Is it, really? In that case we can create a pr on that repo adding wasm target. That's wonderful news!
Will save shitloads of time for me
r
Yeah, it's an MPP build now
b
Wait, no. It won't be able to see my dom bindings :/
r
If you implement the TagConsumer interface (https://github.com/Kotlin/kotlinx.html/blob/master/src/commonMain/kotlin/api.kt) you can build your dom as the dsl code is executed. You can specify the type it will generate.
So the only thing it gives you is the dsl. You can specify what it generates yourself. Would that work?
b
Hmm, it just might! Will have a better look when I'm back to my pc
r
Btw, this also makes me wonder about workers, it doesn't need to be wasm for me. Did you consider that?
b
Not familiar with workers at all. But the idea of this whole project is to enable ppl to move even further away from js on web. Hate that shit! 😀
r
Yeah me to, kotlin/js works really good for me.
b
Tgat file uses w3c dom package, so might be an issue not having that available on wasm
r
Hmm, workers would probable mis that as well
It's only the events package, so workers probably work.
Ok, thx for the info. I'll play around with it a bit.
👍 1
b
Had a better look at kotlinx html and it looks like they're declaring w3c dependencies as expects. So shouldn't be a problem adding actuals on wasm
This turned out to be a bit more work than I initially expected, so this will have to wait for next kvdom version. I want to focus on bringing wasm support back first