Adam S
09/06/2022, 8:35 PM/servers/test-id
at all...
routing
.on("/", {
log("routing.on HOME")
homepageView()
})
.on(("/servers/(.*)"), { match ->
println("routing.on SERVER $match")
val serverId = match.data[0] as? String ?: error("invalid server id")
println("routing.on SERVER serverId:$serverId")
serverView(FactorioServerId(serverId))
}
)
I can see routing.on HOME
logged, but routing.on SERVER
isn't logged. It was earlier! I've no idea what's wrong...Adam S
09/06/2022, 8:37 PMCannot GET /servers/test-server
when I click on the link in the homepage. The URL has the navigo attribute. I'm doing Routing.init(useHash = false)
, and the routing.updatePageLinks()
trickAdam S
09/06/2022, 8:39 PMRobert Jaros
09/06/2022, 8:44 PMRegExp()
Robert Jaros
09/06/2022, 8:45 PMAdam S
09/06/2022, 9:03 PMwindow.setTimeout({routing.updatePageLinks()}, 0)
trick in a function, then it doesn't workAdam S
09/06/2022, 9:04 PMoverride fun start(state: Map<String, Any>) {
Routing.init(
// root = "/",
// root = window.location.origin,
useHash = false,
strategy = Strategy.ALL,
)
SiteRouting.init()
this.appState = state.toMutableMap()
root("kvapp") {
header().bind(siteStateStore) { state ->
headerNav(state)
}
main().bind(siteStateStore) { state ->
div(className = "container-fluid") {
when (state.view) {
SiteView.HOME -> homePage(state)
SiteView.SERVER -> serverPage(state)
}
}
// window.setTimeout({routing.updatePageLinks()}, 0) // works
SiteRouting.updatePageLinks() // doesn't work...
}
}
object SiteRouting {
...
fun updatePageLinks() {
window.setTimeout({
if (::routing.isInitialized) {
log("updating page links")
routing.updatePageLinks()
}
}, 0)
}
Robert Jaros
09/07/2022, 4:01 AMRouting
instances (your own from SiteRouting
and the one provided by KVision). If you run Routing.init()
(which initializes KVision provided instance) make sure you use it everywhere (and don't create the second instance yourself). Otherwise use something like I've shown earlier (https://kotlinlang.slack.com/archives/CL4C1SLKC/p1662325322349289?thread_ts=1662321374.232579&cid=CL4C1SLKC) and don't use Routing.init()
at all.Adam S
09/09/2022, 2:38 PMAdam S
09/09/2022, 2:39 PMAdam S
09/09/2022, 2:40 PMlateinit var routing: Routing
from KVision and instructing users to create their own instance? I that would make it more clear, and more typical of other usages.Robert Jaros
09/09/2022, 2:42 PMStackPanel
and TabPanel
components, which allow easy routing definitions.Adam S
09/09/2022, 2:43 PMAdam S
09/09/2022, 2:43 PMRobert Jaros
09/09/2022, 2:45 PMAdam S
09/09/2022, 2:46 PMRobert Jaros
09/09/2022, 2:46 PMRobert Jaros
09/09/2022, 2:47 PMRobert Jaros
09/09/2022, 2:48 PMAdam S
09/09/2022, 2:48 PMAdam S
09/09/2022, 2:48 PMAdam S
09/09/2022, 2:49 PM