Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ns ^:figwheel-always om-tut.core
- (:require[om.core :as om :include-macros true]
- [om.dom :as dom :include-macros true]))
- (enable-console-print!)
- (println "Edits to this text should show up in your developer console!")
- ;; define your app data so that it doesn't get over-written on reload
- (defonce app-state (atom
- {:contacts
- [{:first "Ben" :last "Bitdiddle" :email "benb@mit.edu"}
- {:first "Alyssa" :middle-initial "P" :last "Hacker" :email "aphacker@mit.edu"}
- {:first "Eva" :middle "Lu" :last "Ator" :email "eval@mit.edu"}
- {:first "Louis" :last "Reasoner" :email "prolog@mit.edu"}
- {:first "Cy" :middle-initial "D" :last "Effect" :email "bugs@mit.edu"}
- {:first "Lem" :middle-initial "E" :last "Tweakit" :email "morebugs@mit.edu"}]}))
- (defn middle-name [{:keys [middle middle-initial]}]
- (cond
- middle (str " " middle)
- middle-initial (str " " middle-initial ".")))
- (defn display-name [{:keys [fist last] :as contact}]
- (str last ", " first (middle-name contact)))
- (defn contact-view [contact owner]
- (reify
- om/IRender
- (render [this]
- (dom/li nil (display-name contact)))))
- (defn contacts-view [data owner]
- (reify
- om/IRender
- (render [this]
- (dom/div nil
- (dom/h2 nil "Contact list")
- (apply dom/ul nil
- (om/build-all contact-view (:contacts data)))))))
- (om/root contacts-view app-state
- {:target (. js/document (getElementById "contacts"))})
- (defn on-js-reload []
- ;; optionally touch your app-state to force rerendering depending on
- ;; your application
- ;; (swap! app-state update-in [:__figwheel_counter] inc)
- )
- ;;; browser output
- Contact list
- Bitdiddle, function cljs$core$first(coll){ if((coll == null)){ return null; } else { if(((!((coll == null)))?((((coll.cljs$lang$protocol_mask$partition0$ & (64))) || (coll.cljs$core$ISeq$))?true:false):false)){ return coll.cljs$core$ISeq$_first$arity$1(null); } else { var s = cljs.core.seq(coll); if((s == null)){ return null; } else { return cljs.core._first(s); } } } }
- Hacker, function cljs$core$first(coll){ if((coll == null)){ return null; } else { if(((!((coll == null)))?((((coll.cljs$lang$protocol_mask$partition0$ & (64))) || (coll.cljs$core$ISeq$))?true:false):false)){ return coll.cljs$core$ISeq$_first$arity$1(null); } else { var s = cljs.core.seq(coll); if((s == null)){ return null; } else { return cljs.core._first(s); } } } } P.
- Ator, function cljs$core$first(coll){ if((coll == null)){ return null; } else { if(((!((coll == null)))?((((coll.cljs$lang$protocol_mask$partition0$ & (64))) || (coll.cljs$core$ISeq$))?true:false):false)){ return coll.cljs$core$ISeq$_first$arity$1(null); } else { var s = cljs.core.seq(coll); if((s == null)){ return null; } else { return cljs.core._first(s); } } } } Lu
- Reasoner, function cljs$core$first(coll){ if((coll == null)){ return null; } else { if(((!((coll == null)))?((((coll.cljs$lang$protocol_mask$partition0$ & (64))) || (coll.cljs$core$ISeq$))?true:false):false)){ return coll.cljs$core$ISeq$_first$arity$1(null); } else { var s = cljs.core.seq(coll); if((s == null)){ return null; } else { return cljs.core._first(s); } } } }
- Effect, function cljs$core$first(coll){ if((coll == null)){ return null; } else { if(((!((coll == null)))?((((coll.cljs$lang$protocol_mask$partition0$ & (64))) || (coll.cljs$core$ISeq$))?true:false):false)){ return coll.cljs$core$ISeq$_first$arity$1(null); } else { var s = cljs.core.seq(coll); if((s == null)){ return null; } else { return cljs.core._first(s); } } } } D.
- Tweakit, function cljs$core$first(coll){ if((coll == null)){ return null; } else { if(((!((coll == null)))?((((coll.cljs$lang$protocol_mask$partition0$ & (64))) || (coll.cljs$core$ISeq$))?true:false):false)){ return coll.cljs$core$ISeq$_first$arity$1(null); } else { var s = cljs.core.seq(coll); if((s == null)){ return null; } else { return cljs.core._first(s); } } } } E.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement