Hi,
I am playing around with a SPA application, for this I use reagent, kioo and
secretary.
This is the basic dataflow I currently have:
(session/put! :current-page rules-page) ;set initial page to load, rules-page
is a kioo snippet
; render the main component where main-page is a kioo template defining a basic
layout like navigation and content, etc
; the content is defined by the :current-page which is set by the routing
function below
(reagent/render-component
[main-page]
(.-body js/document))
; these are my routes, for the example only one is relevant I guess
(defn init-sec-routes []
...
(defroute "/rules" [] (session/put! :current-page rules-page)))
Now here comes the point where my head cannot get into the right direction. In
the rules page I need some data from the backend, which I would like to
retrieve with an ajax request (or whatever fits). How would I do that?
I tried this approach with a snippet:
(defsnippet rules-page "templates/rules/index.html" [:#content] []
{
[:#left-side] (let [data (fn-with-ajax-call)...))})
Which doesn't work, as an ajax call works with callbacks for the error /
success cases.
And I had the idea to wrap the snippet generation into another function which
calls the backend like this:
(defn rules-page []
(GET "/datamodel/get-trans"
{:handler #(rules-page-snippet %)
:error-handler #(hel/err-snippet)}))
Which somehow does not work either, as reagent takes whatever the (GET ...)
function returns and not what the callback handler returns. At least that's the
impression I got from the error message.
However, before I keep on making my hands wet in unknown water, I'd like to
hear what the idiomatic approach to this usecase is, or how others solve this
problem at all.
Thanks in Advance,
Sven
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.