How can I redirect url in Karax?
proc createDom(data: RouterData): VNode =
if state.logged:
result = buildHtml(tdiv):
text "logged"
else:
if data.hashPart != "#/login":
# window.location = "#/login"
tḧanks
Although I am Russian and can understand what you're saying, please keep it English on this forum. Rules are rules, and it's our responsibility as community members to keep the information universally available to everyone. Dominik is Polish and Andreas is German but they write and speak English since English is the lingua franca in IT today. Let's follow their example.
I haven't tried Elm but I'm guessing the apparent complexity comes from its strictly functional nature. I.e. you can't just update the current URL, you have to pass the state to a function that returns a new state, with the new URL. You can do the same dance with Karax, too. But there's probably no need.
Also, I don't quite know how to update the current page URL in Karax. You probably can just wrap window.location.href and set it to the needed value.
Maybe @Araq will join the thread and give the right answer.
A good example is Nimforum. Here is how it implements a navigateTo proc: https://github.com/nim-lang/nimforum/blob/master/src/frontend/karaxutils.nim#L73.
You might also want to copy the routing from it: https://github.com/nim-lang/nimforum/blob/master/src/frontend/forum.nim#L83. (Something we need to move into Karax or a package in the long-term)
Yes, Elm complexity comes from its strictly functional nature. Many simple things are complex.
I did tried to use elm architecture in Karax (or similar redux with redux.nim package), but I think it's useless.
I'm excited how Karax apps can be simple (Nim is excellent language)
Just
window.location.href = "#/login"
works well.
thanks