content to set-content

This commit is contained in:
Dan Holmsand 2015-09-08 18:07:29 +02:00
parent b54b1b0957
commit c95a9ec7ba
8 changed files with 14 additions and 17 deletions

View File

@ -31,9 +31,9 @@
(def title "Minimalistic React for ClojureScript")
(defroute "/" []
(dispatch [:content [#'intro/main] title]))
(dispatch [:set-content [#'intro/main] title]))
(defroute main-page "/index.html" []
(dispatch [:content [#'intro/main] title]))
(dispatch [:set-content [#'intro/main] title]))
(tools/reg-page (main-page))

View File

@ -16,5 +16,5 @@
[undodemo/main {:summary true}]])
(defroute path "/news/index.html" []
(dispatch [:content [#'main] "News"]))
(dispatch [:set-content [#'main] "News"]))
(tools/reg-page (path))

View File

@ -13,7 +13,7 @@
(declare main)
(defroute path "/news/any-arguments.html" []
(dispatch [:content [#'main] title]))
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))

View File

@ -12,7 +12,7 @@
(declare main)
(defroute path "/news/reagent-is-async.html" []
(dispatch [:content [#'main] title]))
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))

View File

@ -13,7 +13,7 @@
(declare main)
(defroute path "/news/binary-clock.html" []
(dispatch [:content [#'main] title]))
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))

View File

@ -12,7 +12,7 @@
(declare main)
(defroute path "/news/news050.html" []
(dispatch [:content [#'main] title]))
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))

View File

@ -13,7 +13,7 @@
(declare main)
(defroute path "/news/cloact-reagent-undo-demo.html" []
(dispatch [:content [#'main] title]))
(dispatch [:set-content [#'main] title]))
(tools/reg-page (path))

View File

@ -47,15 +47,12 @@
(defn demo-handler [state [id v1 v2 :as event]]
(case id
:content (do
(let [title (if v2
(str (:title-prefix state) v2)
(str (:default-title state)))]
(when r/is-client
(r/next-tick #(set! js/document.title title)))
(assoc state
:main-content v1
:title title)))
:set-content (let [title (if v2
(str (:title-prefix state) v2)
(str (:default-title state)))]
(when r/is-client
(r/next-tick #(set! js/document.title title)))
(assoc state :main-content v1 :title title))
:set-page (do (secretary/dispatch! v1)
(assoc state :page-name v1))
:goto-page (do