Thread
#compose-web
    Martin Vyšný

    Martin Vyšný

    4 months ago
    Hello, I'm looking for Nikolai Igotti please. I'm interested in integrating Kotlin Compose with the Vaadin framework, but unfortunately I lack knowledge on how the Kotlin Compose compiler plugin works and how it integrates with the concrete compose library implementation (such as compose-web). Anton Arhipov told me that Nikolai could offer me some docs/pointers/initial guidelines. Thank you 🙂
    Igor Demin

    Igor Demin

    4 months ago
    Nikolai Igotti
    You can contact me instead of Nikolay. As far as I know Vaadin renders all components on server side. You want to wrap existing Vaadin components into @Composable functions?
    Martin Vyšný

    Martin Vyšný

    4 months ago
    Thank you for reaching out 🙂 That is exactly correct. Vaadin components exist primarily on JVM; that's the environment where the
    @Composable
    functions will run and will create Vaadin classes, such as Button and Span. Perhaps the solution might be closer to Compose-Desktop because of targeting JVM? I think I'm looking for a document which explains in detail how exactly Compose observes the changes done to the MutableState, and how can I plug in with my Vaadin-related functions 🙂
    Igor Demin

    Igor Demin

    4 months ago
    Perhaps the solution might be closer to Compose-Desktop because of targeting JVM?
    It is probably in between. You need a compose runtime library, which is built for JVM (desktop):
    import org.jetbrains.compose.compose
    
    plugins {
        kotlin("jvm")
        id("org.jetbrains.compose")
    }
    
    repositories {
        mavenCentral()
        maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev|https://maven.pkg.jetbrains.space/public/p/compose/dev>")
        google()
    }
    
    dependencies {
        implementation(compose.runtime)
    }
    and use an approach, which is used for Compose Web for DOM (“compose” dom elements into some existing DOM container) You can look at an example how to integrate Compose with external UI framework. Also you can look at mosaic - it uses Compose (another fork of it) to build a console application.
    You can look at an example
    Note that code can be not optimal there. Instead of
    EmptyApplier
    , you might want something like
    Applier<ExternalComponent>
    . But it is a good start.
    Martin Vyšný

    Martin Vyšný

    4 months ago
    Perfect, thank you, I'll study these resources 🙇
    hfhbd

    hfhbd

    4 months ago
    Couldn’t you just fork compose web and use your html classes (or kotlinx.html)?
    Martin Vyšný

    Martin Vyšný

    4 months ago
    @hfhbd that would make sense if I'd try to target client-side javascript. However, I'm trying to target server-side JVM Vaadin UI components.
    hfhbd

    hfhbd

    4 months ago
    Yeah, thats why replace js dom classes with kotlinx html (or your html lib). But the main implementation of compose dom runtime is the same.
    Fudge

    Fudge

    4 months ago
    I remember multiple cases of people implementing server-sided component with Compose. Here is an example https://github.com/criske/compose-ssr