Closed yzia2000 closed 1 year ago
If I change the above code to something like this:
def renderPages(page: Page) = page match {
case EmailPage => renderEmailPage
case LoginPage => div("Login Page")
case LoginCallbackPage =>
// some sequential processing
div("Redirecting", onClick --> {_ => router.replaceState(EmailPage) } )
}
And click on the "Redirecting" div, the redirection works fine and the EmailPage is rendered. But of course, I cannot expect the user to click here.
def renderPages(page: Page) = page match {
case EmailPage => EventStream.fromValue(renderEmailPage)
case LoginPage => EventStream.fromValue(div("Login Page"))
case LoginCallbackPage =>
EventStream
.unit(true)
.delay(500)
.flatMap(_ =>
router.replaceState(EmailPage)
EventStream.empty
)
}
val app: Div = div(
child <-- router.currentPageSignal.flatMap(renderPages)
)
Apologies for the ugly code but this one works. Basically by adding a delay until the current page renders, and only after using history api, we can make the email page render. But I don't think this is a good idea
Ok, I just noticed the renderOnDomContentLoaded function. When I use this function, it works just fine. I guess this solves the issue for me.
Hi. It would be nice if I could get some insight on this use case. I have a route that is pretty much a callback which I want to immediately redirect to another page after parsing some details from the callback.
However, even after router.replaceState takes effect and url location changes to the EmailPage, the EmailPage is not rendered and I still see "Redirecting".
May I know what would be the right way to go about this use case.