metosin / reitit

A fast data-driven routing library for Clojure/Script

Home Page:https://cljdoc.org/d/metosin/reitit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

crimsonhawk47 opened this issue · 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.