https://kotlinlang.org logo
#kobweb
Title
d

David Herman

07/18/2023, 12:11 AM
🕸️ Latest Kobweb releases... 0.13.9 is a fun one! 🕸️ https://github.com/varabyte/kobweb/releases/tag/v0.13.8 https://github.com/varabyte/kobweb/releases/tag/v0.13.9 0.13.8 Pre-0.13.8, the logic for SimpleGrid was hardcoded in a way that columns maxed out at 6. However, with the power of CSS variables, the number of columns is now only bounded by your imagination. 🌈
Copy code
SimpleGrid(numColumns(10)) {
    repeat(30) {
        Box(Modifier.size(50.px).backgroundColor(Color.Companion.rgb(Random.nextInt())))
    }
}
(See attached image) 0.13.9 The latest release introduces persistent client-server connections (think WebSockets) via a feature called API streams (a new companion to API routes, the way you declare REST endpoints in Kobweb) Declaring and using streams will likely be a little more involved in practice, but for the simple case of just sending text back and forth, you're looking at some nice one-liners. Here, the following code sends text to the server which then immediately gets echoed back to the client (and logged to the console):
Copy code
// Backend
val echo = ApiStream { ctx -> ctx.stream.send(ctx.text) }

// Frontend
val echoStream = rememberApiStream("echo") { ctx -> console.log("Echoed: ${ctx.text}") }
// later:
echoStream.send("Hello!")
A Kobweb power-user put together a chess playground is less than two days (see attached video). Tons of potential in this feature! Hope the community has fun with it.
🌈 1
😍 5