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?(rfh/push-state history ::results)
Is this a new app?
What do you mean? I started working on it a few months ago
ok, nvm; I made some reitit glue https://github.com/tape-framework/router but it's predicated on specific infrastructure.
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?
pass it to whom?
I'd imagine you put it in a ratom to be displayed