Hi Mike,
Ok, I get that I can take the data from the atom. I still have trouble
accepting that data has to be synchronized between server and local client
state, but I think I get used to that. I am just not sure if I like the
complexity of keeping both synchronized.
> Now you can call do-load-data to initialize the data (probably from some
> 'init' function) or just whenever you need to refresh from the server.
And that's that part I cannot get solved, ok, I do have an init function for
the whole page, I can load the data there, that is ok, but that only loads it
once.
My Idea was that every time I "open" a page I make an ajax call to the backend
and this is still not clear to me how to do that using kioo.
I have secretary dispatching on a route and this loads directly a kioo
defsnippet and I don't see how or where I can make a ajax call.
I mean, if I keep all the state locally in a an atom I don't need that call
except on the first whole page load, but like I said, I have trouble accepting
that kind of state handling.
Maybe I just need some good words on it :D
Thanks,
Sven
Am Montag, 3. November 2014 01:17:36 UTC+1 schrieb Mike Haney:
> Right, this is standard asynchronous programming. It takes awhile to wrap
> your head around it if you haven't done much of it before.
>
> It looks like you are using the session namespace from Dmitri's examples
> (excellent starting point, BTW). Since this is already wrapping a reagent
> atom, the easiest fix is to just have your 'rules-page' pull the data from
> the session:
>
> (defn rules-page []
> (let [error? (session/get :error)]
> (if error?
> [hel/err-snippet]
> [rules-page-snippet (session/get :data)])))
>
> Now you need to move your ajax call to a separate function:
>
> (defn do-load-data []
> (GET "/datamodel/get-trans"
> {:handler (fn [res]
> (session/put! :error false)
> (session/put! :data %))
> :error-handler #(session/put! :error true)}))
>
> Now you can call do-load-data to initialize the data (probably from some
> 'init' function) or just whenever you need to refresh from the server.
--
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.