https://kotlinlang.org logo
Join SlackCommunities
Powered by
# kvision
  • a

    althaf

    12/23/2024, 12:39 PM
    I can see that in your new project https://github.com/rjaros/kilua , you have introduced support for the tailwind
  • c

    Christer Palm

    12/23/2024, 12:52 PM
    @Robert Jaros Following up on my RestClient/deserialization challenges... Indeed, moving from LegacyRestClient to RestClient did not improve deserialization performance at all ๐Ÿ˜ž Using requestDynamic() improves performance greatly, but some objects need to be Kotlin objects down the road. Fortunately, the bulk of the REST response works just as well with plain JS objects. For elegance, I'm wondering if it's possible to make a hybrid approach? Something like:
    Copy code
    @Serializable
    data class MyResponseType(
        val hugeListThatDoesntNeedDeserialization : dynamic,
        val deserializeThis : MyType,
        val deserializeThisToo : Array<String>,
    )
    
    ...
        val responsePromise : Promise<RestResponse<MyResponseType>> = restClient.receive<MyResponseType, Nothing>(url) {
            deserializer = MyResponseType.serializer()
        }
    I.e. tell the Kotlin deserializer to leave some elements alone? Does receive() even work off JS objects, or does it work with a character stream? I know that's more of a deserialization question, but maybe you know?
    r
    • 2
    • 15
  • a

    althaf

    12/23/2024, 2:12 PM
    @Christer Palm, i'm asking our of curiosity. What is stopping you from Using Retrofit for Rest Calls ? From their website they mentioned
    Copy code
    A type-safe HTTP client for Android and Java
  • c

    Christer Palm

    12/23/2024, 3:02 PM
    @althaf: I don't know, I'm not at all familiar with Retrofit. Though the application I'm maintaining neither uses Android, nor Java.
  • m

    Mark Fisher

    01/02/2025, 6:58 PM
    Hi, I've just converted an existing project to include kvision, I've got the web application to run with jsRun, but I'm having trouble getting HMR to work. The app is just a hello world, I'm using intellij, and was trying to get some basic dev env setup.
    Copy code
    override fun start() {
            root("kvapp") {
                flexPanel(FlexDirection.ROW, justify = JustifyContent.CENTER) {
                    div("Hello world!") {
                        marginTop = 50.px
                        fontSize = 50.px
                    }
                }
            }
        }
    Starting the application from cli using gradle, my message is displayed at localhost:3000, but when I change the div text, although I see webpack reporting it's compiled, neither a normal browser (chrome) or debug javascript browser from within IntelliJ are showing the altered text, even when refreshing the page. Logs when I save a change in WebApp.kt (the above taken from)
    Copy code
    โฏ ./gradlew :server:jsRun
    Starting a Gradle Daemon, 1 busy and 1 incompatible and 5 stopped Daemons could not be reused, use --status for details
    
    > Configure project :server
    w: 'java' Gradle plugin is not compatible with 'org.jetbrains.kotlin.multiplatform' plugin.
    
    Consider adding a new subproject with 'java' plugin where the KMP project is added as a dependency.
    
    
    > Task :server:jsBrowserDevelopmentRun
    <i> [webpack-dev-server] [HPM] Proxy created: /kv/*,/kvsse/*  -> <http://localhost:8080>
    <i> [webpack-dev-server] [HPM] Proxy created: /login,/logout  -> <http://localhost:8080>
    <i> [webpack-dev-server] [HPM] Proxy created: /kvws/*  -> <http://localhost:8080>
    <i> [webpack-dev-server] Project is running at:
    <i> [webpack-dev-server] Loopback: <http://localhost:3000/>
    <i> [webpack-dev-server] On Your Network (IPv4): <http://192.168.1.100:3000/>
    <i> [webpack-dev-server] Content not from webpack is served from 'kotlin, ..\..\..\..\server\build\processedResources\js\main' directory
    <i> [webpack-dev-server] 404s will fallback to '/index.html'
    webpack 5.94.0 compiled successfully in 1084 ms
    webpack 5.94.0 compiled successfully in 21 ms
    webpack 5.94.0 compiled successfully in 30 ms
    I'm wondering what I'm doing wrong. Sorry for the beginner question.
    r
    • 2
    • 7
  • m

    Mark Fisher

    01/02/2025, 7:01 PM
    Also, on a separate note, when I start the application, I see a gradle warning:
    Copy code
    > Configure project :server
    w: 'java' Gradle plugin is not compatible with 'org.jetbrains.kotlin.multiplatform' plugin.
    I tracked this down to the plugin "io.kvision". Commenting this plugin out stops the warning, but then the webapp doesn't work. I saw it's also displaying on the example apps, so assume it's expected but just unfortunate?
    r
    • 2
    • 2
  • m

    Mark Fisher

    01/03/2025, 9:02 AM
    Is this how I am add an
    id
    to an element? It works, I'm just wondering if there's another way when creating the simplePanel etc.
    Copy code
    simplePanel(className = "page-header") {
        setAttribute("id", "banner")
    r
    • 2
    • 2
  • m

    Mark Fisher

    01/03/2025, 11:34 AM
    More simple questions (hopefully)! I'm trying to achieve this output:
    Copy code
    <li class="list-group-item d-flex justify-content-between align-items-center">
      Client Count
      <span class="badge bg-primary rounded-pill">3</span>
    </li>
    When I use the following, the text content of the
    li
    is put in after the span:
    Copy code
    simplePanel(className = "bs-component") {
        ul(className = "list-group") {
            li(className = "list-group-item d-flex justify-content-between align-items-center") {
                content = "Client Count"
                span(className = "badge bg-primary rounded-pill") {
                    content = "3"
                }
            }
        }
    }
    i.e. it's producing:
    Copy code
    <li class="list-group-item d-flex justify-content-between align-items-center kv-text-start">
      <span class="badge bg-primary rounded-pill">3</span>
      Client Count
    </li>
    How do I get the content to be put in before the child span?
    r
    • 2
    • 8
  • m

    Mark Fisher

    01/09/2025, 6:48 PM
    Hi, I have a KVision project I'm trying to create a jar for, but the shadowJar task isn't being included. When I look at one of the demo projects for ktor (addressbook-fullstack-ktor) and print the taskinfo tree I see:
    Copy code
    :jar                                                                                                  (org.gradle.api.tasks.bundling.Jar)
    +--- :classes                                                                                         (org.gradle.api.DefaultTask)
    | ... removed for clarity
    +--- :compileJava                                                                                     (org.gradle.api.tasks.compile.JavaCompile)
    `--- :shadowJar                                                                                       (org.gradle.api.tasks.bundling.Jar)
         +--- :jsArchive                                                                                  (org.gradle.api.tasks.bundling.Jar)
         |    `--- :jsBrowserDistribution                                                                 (org.gradle.api.tasks.Copy)
    ... etc
    but with my own project, the shadowJar task is not listed, and thus my "jar" task isn't creating a fat jar file. Where is the shadowJar being pulled in from? I can't see it directly added to the example project, but it's there.
    r
    • 2
    • 17
  • m

    Mark Fisher

    01/09/2025, 7:16 PM
    When I add the
    io.ktor:ktor-server-config-yaml-jvm
    dependency to a project, and build the
    jar
    task, the default
    io.ktor.server.config.HoconConfigLoader
    is not being added to the list of ConfigLoaders in
    META-INF/services/io.ktor.server.config.ConfigLoader
    This has the knock on effect that the "application.conf" file in the root of the jar is not able to be loaded, as there is no ConfigLoader class available to handle that file type. See thread. I've reproduced this in the examples application.
    r
    • 2
    • 6
  • r

    Robert Jaros

    01/14/2025, 1:06 PM
    Please help me decide on further development of KVision. Vote! 1๏ธโƒฃ Maintain backward compatibility for as long as possible. Make breaking changes only when required by the development of core tools and libraries (e.g. KGP). Keep current modules up to date, even if they're probably not being used by anyone. 2๏ธโƒฃ Modernize! Support ES modules, TailwindCSS, kotlinx-datetime, Kilua RPC integration, at the expense of having to make changes (sometimes significant) to my existing projects. Deprecate and drop modules which require a lot of work to maintain and are not used often or at all. 3๏ธโƒฃ Let it burn! Focus on Kilua development (I'm already migrating my applications!) ๐Ÿ˜‰ 4๏ธโƒฃ I have different opinion (please leave a comment)
    2๏ธโƒฃ 5
    1๏ธโƒฃ 1
    3๏ธโƒฃ 5
    4๏ธโƒฃ 1
    r
    • 2
    • 1
  • r

    Robert Jaros

    01/18/2025, 4:44 PM
    KVision 8.1.1 is out https://github.com/rjaros/kvision/releases/tag/8.1.1
    ๐ŸŽ‰ 4
  • r

    Robert Jaros

    01/18/2025, 4:46 PM
    The API documentation made with Dokka 2.0 is so much better.
  • r

    Robert Jaros

    02/07/2025, 8:30 PM
    KVision 8.2.0 is out https://github.com/rjaros/kvision/releases/tag/8.2.0
    ๐ŸŽ‰ 4
  • c

    Christer Palm

    02/17/2025, 5:24 PM
    Help me understand this KVision pattern(?) The application I'm maintaining has a Container.mainLoop() function which basically does:
    Copy code
    fun Container.mainLoop() {
        main().bind(store) { state ->
            /* Render the view according to state */
        }
    }
    I suppose the basic idea here is that the view is re-rendered whenever there is a state change(?) The problem I'm having is that this happens asynchronously. The application goes through a number of state changes, but instead of re-rendering the page after each state change in realtime they queue up and after everything has settled, the page is re-rendered multiple times back-to-back, which is pointless. The application really just needs to reflect the "final" state change. Is this a bad pattern? Is there a better "best practice" approach to this? Thanks!
    r
    • 2
    • 12
  • r

    Robert Jaros

    04/15/2025, 9:41 AM
    KVision 9.0.0 is out https://github.com/rjaros/kvision/releases/tag/9.0.0
    ๐ŸŽ‰ 2
  • r

    Robert Jaros

    04/15/2025, 9:45 AM
    The documentation update will take some time, so the migration guide is not ready yet.
  • r

    Robert Jaros

    04/15/2025, 9:48 AM
    KVision is now simplified. There are no fullstack modules, no Electron, no Cordova and no OnsenUI. The framework itself and all example apps are migrated to ES2015 target and ES modules.
  • r

    Robert Jaros

    04/15/2025, 9:49 AM
    There is new TailwindCSS module and ready to run example application.
  • r

    Robert Jaros

    04/15/2025, 9:50 AM
    Examples repository has also been simplified and all fullstack examples use Kilua RPC now.
    ๐ŸŽ‰ 5
    ๐Ÿ‘ 1
    ๐Ÿ‘๐Ÿพ 1
  • c

    Christer Palm

    04/17/2025, 9:31 AM
    Anyone had any success with using chart.js date adapters with KVision? I naively tried to add an (NPM) dependency to an adapter in the build, but no cigar ๐Ÿ˜ž
    r
    • 2
    • 18
  • r

    Robert Jaros

    04/17/2025, 3:47 PM
    KVision guide has been fully updated to version 9.0.0. And the new fullstack chapter just references Kilua RPC guide.
  • r

    Robert Jaros

    04/17/2025, 3:48 PM
    The old version of the guide is still available as https://kvision.gitbook.io/kvision-guide/kvision-8.x
  • r

    Robert Jaros

    04/20/2025, 5:43 AM
    KVision 9.0.1 is out https://github.com/rjaros/kvision/releases/tag/9.0.1
    ๐Ÿ‘ 2
    ๐ŸŽ‰ 2
    ๐Ÿ‘๐Ÿพ 1
  • p

    Phil Richardson

    04/22/2025, 2:58 PM
    Does Kilua RPC support returning objects? They are not mentioned, but inline with the Kotlin Serialization guide,
    Unit
    is just a singleton object, and it is handled like any other Kotlin object. But Kilua rules out Unit as a return type, which has me wondering about objects in general
  • r

    Robert Jaros

    04/22/2025, 3:21 PM
    Yes, Kilua RPC supports returning any serializable class. But not
    Unit
    . Is
    Unit
    serializable? (I'm not sure ๐Ÿ™‚)
  • r

    Robert Jaros

    04/22/2025, 4:03 PM
    LOL. When I created KVision fullstack interfaces years ago returning
    Unit
    was not possible. I've just accepted this rule, because it was not a big problem for me. Years passed and I've made changes here and there, replacing old, manual deserialization code with features from the kotlinx.serialization lib. But I've never ever tried returning
    Unit
    ... until today ๐Ÿ˜‰ And it works!
  • r

    Robert Jaros

    04/22/2025, 4:13 PM
    Thanks for your question @Phil Richardson ๐Ÿ™‚
  • p

    Phil Richardson

    04/22/2025, 4:16 PM
    https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/builtin-classes.md#unit-and-singleton-objects
    The Kotlin builtin Unit type is also serializable. Unit is a Kotlin singleton object, and is handled equally with other Kotlin objects.
    I see your comment about testing returning Unit. Good to hear, as my question was initially aimed at using some other marker object in place of Unit, given the docs says Unit cannot be a return type. Unlike the Nothing non-type, everything I knew about Unit said it is just an object, thus wondering if that made objects barred.
  • c

    Christer Palm

    05/05/2025, 8:33 AM
    Hi! More Chart.js hurdles... io.kvision.chart.DataSets has a member minBarLegth. I think that should be minBar_Length_? Either way it doesn't seem to work. Can I work around this and pass DataSets options in a non-typed way?
    r
    • 2
    • 24