I’ve just published KVision - a new open source framework for building web applications in Kotlin. It’s available at https://github.com/rjaros/kvision.
KVision gives you a hierarchy of many different components, which are used to build application UI. It integrates many JavaScript, CSS and Kotlin-based components and projects (Bootstrap, Snabbdom, Font awesome, Trix editor, Kotlin observables and others) to give you an uniform working environment.
Additional information, examples and API documentation is available from the GitHub page.
At a first glance it is more mature then the one presented here few days ago.
The problem I see here is the lack of kotlin-style builders. Code like that:
looks ugly in kotlin. It could easily be reduced with apply block. Also with a little effort, one could add builder functions, which could make the API much more comprehensible. Like that:
class VPanel(...){
...
fun button(title: String, ..., op: (Button) -> Unit){
this.add(Button(title, ... ).apply (op))
}
}
Thanks for your feedback!
I’ve published version 0.0.3 with new DSL builders for all containers and components. The builders are made with extension functions so it is even possible to write such functions for new, custom components.
I’ve refactored examples to use these kotlin-style builders, too.
@rjaros I had a look at the examples and I really liked it. I find JS a bit chaotic. Do you thin it is possible to use KVision to write a single page JS REST client that requests and responds in json from and to different endpoints over HTTPS? I guess it would also need some notion of state and routing.
It’s definitely possible. At the moment KVision doesn’t have any dedicated methods to call REST endpoints, but it has integrated jQuery bindings and some helper extension functions as well. So you can simply write:
jQuery.post("/rest_url", mapOf("key1" to "value1", "key2" to "value2").asJson(), { data, status, xhr ->
console.log(data)
console.log(status)
console.log(xhr)
})
OK. Is there plans for dedicated methods to call REST endpoint?. I like to stay away from JS as much as possible even though the current approach doesn’t look to overwhelming.
I plan to add dedicated api for remote endpoints, but first I have to think it through. I would like it to be as optimal as possible to use and I have to learn more about coroutines and promises
Address book sample application uses fully transparent and automatic endpoint generation (both on the server and client side). So you will not find any code responsible for these HTTP calls.
But if you want to call your own endpoint you can use “remoteCall” method of “pl.treksoft.kvision.remote.CallAgent” class. It’s a simple wrapper over jQuery.ajax(), which allows you to specify request parameters, send any data and get Promise of the response (which can be converted to Deferred and used inside coroutines if you want to).