-
-
Save s-mage/de762339fc1909a271a1 to your computer and use it in GitHub Desktop.
reagent example for clojurians
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 routes | |
{:. home/view | |
"sign_in" sign-in/view | |
"sign_up" sign-up/view | |
"videos" { | |
:. #(videos/index-view nil) | |
[:id] {:. #(videos/index-view %) | |
"status" {[:status] #(videos/index-view %)}}} | |
"cases" { [:id] cases/view } | |
}) | |
(defn current-page [] | |
(session/get :current-page)) | |
(defn dispatch! [path] | |
(session/put! :current-page | |
(let [path (if (helpers/need-login? path) "/sign_in" path)] | |
(if-let [r (rm/match path routes)] | |
(if-let [p (:params r)] | |
#((:match r) p) | |
(:match r)) | |
not-found/view))) | |
(render-component ((current-page)) (sel1 "#app"))) |
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
(defn index-view [{:keys [id status]}] | |
[:div | |
[:main | |
(header/view) | |
[:div.row.videos-list>div.large-12.columns (search-form search-video!)] | |
[:div.row.videos-list>div.large-12.columns (pages-stats-handler (:pages-statistics @state))] | |
[:div.row.videos-list>div.large-12.columns | |
(main (videos/videos-to-show status) @links (if (nil? id) id (int id)))] | |
[:br] | |
[:div.row.videos-list>div.large-6.columns | |
(apply pagination | |
(conj (into [] ((juxt :page-number :page-size) @state)) | |
(videos/video-ids @links) | |
change-page! | |
#(videos/request-videos links state)))]] | |
(footer/view)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment