Skip to content

Instantly share code, notes, and snippets.

@Deraen
Last active November 22, 2015 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deraen/be6a7d4b6bf1fc26597a to your computer and use it in GitHub Desktop.
Save Deraen/be6a7d4b6bf1fc26597a to your computer and use it in GitHub Desktop.
(def app-state (atom {:user/role :admin
:links/by-id {"1" {:_id "1" :url "" :title "" :favicon "" :likes 0}}
:links/all [[:links/by-id "1"]}))
(defui Link
static om/Ident
(ident [this {:keys [_id]}]
[:links/by-id _id])
static om/IQuery
(query [this]
[:_id :title :url :favicon :likes])
Object
(render [this]
;; NOTE: In addition to link's properties, this component needs user/role
(let [{:keys [_id title url favicon likes user/role] :as props} (om/props this)]
...)))
(defui Main
static om/IQuery
(query [this]
(let [subquery (om/get-query Link)]
`[:user/role {:links/all ~subquery}]))
Object
(render [this]
(let [{:keys [links/all user/role]} (om/props this)]
;; I can access user/role here but how to pass it to Link components?
(html
[:ul (for [x all]
(link x))]))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment