Fork me on GitHub
#reitit
<
2020-12-21
>
GGfpc23:12:24

Hello! I'm trying to use reitit frontend to redirect to another page. Basically, I have an AJAX request that loads some data that could take a long time to compute, so I want to have a loading page that redirects to the presentation page when the request is done (passing along the data) This is my current reitit setup which is almost entirely based on the reitit frontend easy github example

(defonce match (ratom/atom nil))

(defn current-page []
  [:div
   [:ul
    [:li [:a {:href (rfe/href ::stats)} "Stats"]]]
   (if @match
     (let [view (:view (:data @match))]
       [view @match]))
   ])


(def routes
  [["/process"
    {:name ::stats
     :view process}]
   ["/results"
    {:name ::results
     :view stats/statistics-component}]])


(defn init! []
  (rfe/start!
    (rf/router routes {})
    (fn [m] (reset! match m))
    ;; set to false to enable HistoryAPI
    {:use-fragment true})
  (rdom/render [current-page] (.getElementById js/document "app")))
I want to call /process, have it send the ajax request and call results and pass the response. I want /results to be a different page so that I don't have to download a bunch of css until I get the actual data. How can I accomplish this with reitit?

clyfe08:12:37

(rfh/push-state history ::results)

👍 3
clyfe08:12:00

Is this a new app?

GGfpc11:12:05

What do you mean? I started working on it a few months ago

clyfe11:12:29

ok, nvm; I made some reitit glue https://github.com/tape-framework/router but it's predicated on specific infrastructure.

GGfpc18:12:01

So I was reading your answer, and I was able to move to the correct page, but how do I pass the ajax request response?

clyfe19:12:35

pass it to whom?

clyfe19:12:07

I'd imagine you put it in a ratom to be displayed