-
-
Save Deraen/be6a7d4b6bf1fc26597a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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