File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" )})
You can’t perform that action at this time.
0 commit comments