reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
GGfpc 2020-12-21T23:28:24.439900Z

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?

clyfe 2020-12-22T08:46:37.440Z

(rfh/push-state history ::results)

👍 1
clyfe 2020-12-22T08:47:00.440200Z

Is this a new app?

GGfpc 2020-12-22T11:15:05.440400Z

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

clyfe 2020-12-22T11:20:29.440700Z

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

GGfpc 2020-12-22T18:56:35.441100Z

@claudius.nicolae

GGfpc 2020-12-22T18:57:01.441300Z

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?

clyfe 2020-12-22T19:00:35.441500Z

pass it to whom?

clyfe 2020-12-22T19:01:07.441700Z

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