You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In choo v6.8.0, emitting pushState (e.g. emit('pushState', '/')) in a route handler should have the documented behaviour of navigating to the indicated page.
My use case is to redirect the user to the homepage from f.ex. the login page if the user is already logged in.
Actual behavior
When emitting this event in a route handler, it appears to do nothing. Instead I defer the event to be emitted asynchronously, which makes it work: setTimeout(() => {emit.global('pushState', '/')}, 0)
Steps to reproduce behavior
Emit the pushState event in a route handler, in my experience it'll be a no-op:
emit('pushState', '/')
The text was updated successfully, but these errors were encountered:
I found out that the reason for the pushState event being a no-op during a render pass being that nanoraf will suppress any render requests while already rendering. The question is if choo should handle this scenario and defer the handling of the event until after the render pass (i.e. as I do with setTimeout), on behalf of the client?
I think ideally we would detect that pushState was emitted in a route handler and bail out of rendering the current route, then render the new route. I think deferring on behalf of the client makes sense, even if just to maintain the async behaviour of pushState, so that
Expected behavior
In choo v6.8.0, emitting
pushState
(e.g.emit('pushState', '/')
) in a route handler should have the documented behaviour of navigating to the indicated page.My use case is to redirect the user to the homepage from f.ex. the login page if the user is already logged in.
Actual behavior
When emitting this event in a route handler, it appears to do nothing. Instead I defer the event to be emitted asynchronously, which makes it work:
setTimeout(() => {emit.global('pushState', '/')}, 0)
Steps to reproduce behavior
Emit the
pushState
event in a route handler, in my experience it'll be a no-op:The text was updated successfully, but these errors were encountered: