Skip to content

Commit 321890e

Browse files
committed
rendering contacts
1 parent 4586245 commit 321890e

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src-cljs/modern_clj_web/core.cljs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@
1010

1111
(println "hello from clojurescript")
1212

13-
(go
14-
(let [response (<! (http/get "/contacts"))]
15-
(println (:body response))))
13+
(defn get-contacts []
14+
(go
15+
(let [response (<! (http/get "/contacts"))]
16+
(:body response))))
1617

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

19-
(defcomponent app [data owner]
20+
(defcomponent contact-comp [contact _]
2021
(render [_]
21-
(dom/div (:message data))))
22+
(dom/li (str (:firstname contact) " " (:lastname contact)))))
23+
24+
(defcomponent app [data _]
25+
(will-mount [_]
26+
(go
27+
(let [contacts (<! (get-contacts))]
28+
(om/update! data :contacts contacts))))
29+
(render [_]
30+
(dom/div
31+
(dom/h2 (:message data))
32+
(dom/ul
33+
(om/build-all contact-comp (:contacts data))))))
2234

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

0 commit comments

Comments
 (0)