reitit icon indicating copy to clipboard operation
reitit copied to clipboard

Pushing state inside frontend controllers causes the on-navigate function run in the wrong order.

Open crimsonhawk47 opened this issue 1 year ago • 0 comments

I was trying to put redirects in my controllers based on session state. For instance, if someone navigates to an admin page, they need to be logged in.

I have an on-navigate function like what is shown in the frontend example in controllers.md. Because I'm trying to do redirects, my controllers might use rfe/push-state. But if you call this inside a controller, the on-navigate function gets router matches in reverse order.

So calling in this order: (rfe/push-state :home) -> (rfe/push-state :login) gets matches in the order of /login -> /home.

This leads to an issue where my match atom has the wrong state and the browser has the right state.

crimsonhawk47 avatar Aug 14 '23 21:08 crimsonhawk47