mirror of
https://github.com/status-im/reagent.git
synced 2025-01-14 05:45:06 +00:00
Update demo to use rswap!
and fix old-style url in new051
This commit is contained in:
parent
be1dfaeba7
commit
f62bf44661
@ -6,7 +6,7 @@
|
|||||||
[sitetools.core :as tools :refer [link]]
|
[sitetools.core :as tools :refer [link]]
|
||||||
[reagentdemo.common :as common :refer [demo-component]]))
|
[reagentdemo.common :as common :refer [demo-component]]))
|
||||||
|
|
||||||
(def url "news/news051.html")
|
(def url "/news/news051.html")
|
||||||
(def title "News in 0.5.1")
|
(def title "News in 0.5.1")
|
||||||
|
|
||||||
(def ns-src (s/syntaxed "(ns example.core
|
(def ns-src (s/syntaxed "(ns example.core
|
||||||
|
@ -9,25 +9,6 @@
|
|||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
||||||
(defn rswap! [a f & args]
|
|
||||||
;; Like swap!, except that recursive swaps on the same atom are ok,
|
|
||||||
;; and always returns nil.
|
|
||||||
{:pre [(satisfies? ISwap a)
|
|
||||||
(ifn? f)]}
|
|
||||||
(if a.rswapping
|
|
||||||
(-> (or a.rswapfs (set! a.rswapfs (array)))
|
|
||||||
(.push #(apply f % args)))
|
|
||||||
(do (set! a.rswapping true)
|
|
||||||
(try (swap! a (fn [state]
|
|
||||||
(loop [s (apply f state args)]
|
|
||||||
(if-some [sf (some-> a.rswapfs .shift)]
|
|
||||||
(recur (sf s))
|
|
||||||
s))))
|
|
||||||
(finally
|
|
||||||
(set! a.rswapping false)))))
|
|
||||||
nil)
|
|
||||||
|
|
||||||
|
|
||||||
;;; Configuration
|
;;; Configuration
|
||||||
|
|
||||||
(declare main-content)
|
(declare main-content)
|
||||||
@ -69,7 +50,7 @@
|
|||||||
|
|
||||||
(defn dispatch [event]
|
(defn dispatch [event]
|
||||||
;; (dbg event)
|
;; (dbg event)
|
||||||
(rswap! config demo-handler event))
|
(r/rswap! config demo-handler event))
|
||||||
|
|
||||||
(defn register-page [url comp title]
|
(defn register-page [url comp title]
|
||||||
{:pre [(re-matches #"/.*[.]html" url)
|
{:pre [(re-matches #"/.*[.]html" url)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user