Alexander Vasiljev
09/21/2018, 8:24 AMDeactivated User
09/21/2018, 8:25 AMAlexander Vasiljev
09/21/2018, 8:29 AM@Location("/products")
class Products
@Location("/platforms")
class Platforms
@Location("/deviceModels")
class DeviceModelsAlexander Vasiljev
09/21/2018, 8:31 AMa(href = "/products") { +"Products" } one is able to a(href = href(Products())) { +"Products" } -- the feature is great!Alexander Vasiljev
09/21/2018, 8:36 AMhref(Products())) inside the template. Corresponding function href is available only in Routing context. For now I am using the trick:
var href: (Any) -> String = { "" }
fun Routing.commonRoutes() {
    href = fun(location: Any): String { return application.locations.href(location) }
  // etc.
and wonder if more elegant solution might exist?Alexander Vasiljev
09/21/2018, 8:55 AMDeactivated User
09/21/2018, 8:57 AMDeactivated User
09/21/2018, 9:01 AMTemplate subclass with a call: ApplicationCall, and make a href method or extension method for that class that calls the right method with the right contextDeactivated User
09/21/2018, 9:02 AMAlexander Vasiljev
09/21/2018, 10:21 AMfun Routing.productRoutes() {
    get<Products> { _ ->
        call.respondHtmlTemplate(
                ListTemplate(
                        title = "All products",
                        tableModel = allProductTableModel(),
                        href = fun(location: Any) = this@productRoutes.application.locations.href(location)
                )
        ) {}
    }
}
same code for every get or postAlexander Vasiljev
09/21/2018, 10:22 AMfun Routing.productRoutes() {
    get<Products> { _ ->
        call.respondHtmlTemplate(
                ListTemplate(title = "All products", tableModel = allProductTableModel())
        ) {}
    }
}Alexander Vasiljev
09/21/2018, 10:24 AMorangy
Locations is a feature that needs much more attention, but unfortunately right now we don’t have enough resource. It’s not about coding, more about designing it better.orangy
orangy
Location feature instance, so it shouldn’t be too hard?orangy
Application instance and use it everywhere.orangy
Alexander Vasiljev
09/21/2018, 10:40 AMorangy
Deactivated User
09/21/2018, 10:43 AMcoroutineContext as a dependency container 🤨, like a scala implicit. Though I wouldn’t do that either
the main problem with globals (in addition to multithreading issues) is testing or multiple applications, you normally want to start things from scratch. Even when in control at the beginning, it is a bad practice in generalAlexander Vasiljev
09/21/2018, 10:43 AMIt’s not about coding, more about designing it better.So I provided you with feedback from a real world application. Anyway, thank you for a wonderful framework.
orangy
orangy
Alexander Vasiljev
09/21/2018, 10:49 AMor Location instanceI do not see that Location instance would be of any use though. E.g. there are actually @Location("/products") class Products { @Location("/{id}") class Item(val id: Int) } and later:
private fun ProductModel.asRowModel(): RowModel {
    return RowModel(listOf(RefCell(id) { href(Products.Item(id)) }, PlainCell(name)))
}
It is possible to embed links into list view. Each to corresponding item: href(Products.Item(id)) for every item in the listorangy
Locations feature instance, like application.locationsAlexander Vasiljev
09/21/2018, 10:51 AMDeactivated User
09/21/2018, 10:54 AMAlexander Vasiljev
09/21/2018, 11:31 AM