althaf
12/23/2024, 12:39 PMChrister Palm
12/23/2024, 12:52 PM@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?althaf
12/23/2024, 2:12 PMA type-safe HTTP client for Android and Java
Christer Palm
12/23/2024, 3:02 PMMark Fisher
01/02/2025, 6:58 PMoverride 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)
โฏ ./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.Mark Fisher
01/02/2025, 7:01 PM> 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?Mark Fisher
01/03/2025, 9:02 AMid
to an element? It works, I'm just wondering if there's another way when creating the simplePanel etc.
simplePanel(className = "page-header") {
setAttribute("id", "banner")
Mark Fisher
01/03/2025, 11:34 AM<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:
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:
<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?Mark Fisher
01/09/2025, 6:48 PM: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.Mark Fisher
01/09/2025, 7:16 PMio.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.Robert Jaros
01/14/2025, 1:06 PMRobert Jaros
01/18/2025, 4:44 PMRobert Jaros
01/18/2025, 4:46 PMRobert Jaros
02/07/2025, 8:30 PMChrister Palm
02/17/2025, 5:24 PMfun 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!Robert Jaros
04/15/2025, 9:41 AMRobert Jaros
04/15/2025, 9:45 AMRobert Jaros
04/15/2025, 9:48 AMRobert Jaros
04/15/2025, 9:49 AMRobert Jaros
04/15/2025, 9:50 AMChrister Palm
04/17/2025, 9:31 AMRobert Jaros
04/17/2025, 3:47 PMRobert Jaros
04/17/2025, 3:48 PMRobert Jaros
04/20/2025, 5:43 AMPhil Richardson
04/22/2025, 2:58 PMUnit
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 generalRobert Jaros
04/22/2025, 3:21 PMUnit
. Is Unit
serializable? (I'm not sure ๐)Robert Jaros
04/22/2025, 4:03 PMUnit
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!Robert Jaros
04/22/2025, 4:13 PMPhil Richardson
04/22/2025, 4:16 PMThe 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.
Christer Palm
05/05/2025, 8:33 AM