Hey guys
I am fairly new with OM and clojurescript and run into a case where I don’t
know the ‘correct’ way of handling it.
Following example:
Pollview (react component) builds multiple choices through (build-all). If the
user clicks on one of these choices, a ajax request gets fired, the users
choice added and the component refreshed.
Poll uses something like this:
(om/build-all choice (vec (get-in app [:data :choices] nil)))
On choice (defn choice [data, owner]) the first argument is obviously a data
row taken from the app-state. The second argument the owner, so the Pollview -
right?
Once choice does the ajax request, it needs to communicate back to the pollview
that something has changed and either force a refresh or simply change the
app-state itself. But how do I reference back to it? Data is fetched inside the
(will-mount) of the pollview. Can I somehow re-mount the entire view and force
a rebuild?
What I did, after having no success with the ‘owner’ argument, I simply passed
the app-state cursor as options, but that feels very dirty to me:
(om/build-all choice (vec (get-in app [:data :choices] nil)) {:opts {:app
app}}).
Choice is now using the cursor to directly replace the old data with new one.
What is the proper ‘om’ way to handle this?
— David Mohl
--
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.