Skip to content

Commit

Permalink
rendering contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
pjagielski committed Oct 14, 2015
1 parent 4586245 commit 321890e
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src-cljs/modern_clj_web/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,27 @@

(println "hello from clojurescript")

(go
(let [response (<! (http/get "/contacts"))]
(println (:body response))))
(defn get-contacts []
(go
(let [response (<! (http/get "/contacts"))]
(:body response))))

(def app-state (atom {:message "hello from om"}))

(defcomponent app [data owner]
(defcomponent contact-comp [contact _]
(render [_]
(dom/div (:message data))))
(dom/li (str (:firstname contact) " " (:lastname contact)))))

(defcomponent app [data _]
(will-mount [_]
(go
(let [contacts (<! (get-contacts))]
(om/update! data :contacts contacts))))
(render [_]
(dom/div
(dom/h2 (:message data))
(dom/ul
(om/build-all contact-comp (:contacts data))))))

(om/root app app-state
{:target (.getElementById js/document "main")})

0 comments on commit 321890e

Please sign in to comment.