mirror of
https://github.com/status-im/re-frame.git
synced 2025-02-23 07:18:22 +00:00
Move examples to v0.3.1.
Plus undo previous mistaken checkin to todomvc
This commit is contained in:
parent
a12267308e
commit
f69b7cd332
@ -3,8 +3,8 @@
|
|||||||
:dependencies [[org.clojure/clojure "1.6.0"]
|
:dependencies [[org.clojure/clojure "1.6.0"]
|
||||||
[org.clojure/clojurescript "0.0-2816"]
|
[org.clojure/clojurescript "0.0-2816"]
|
||||||
[reagent "0.5.0"]
|
[reagent "0.5.0"]
|
||||||
[re-frame "0.3.0"]
|
[re-frame "0.3.1"]
|
||||||
[figwheel "0.2.3-SNAPSHOT"]]
|
[figwheel "0.2.6"]]
|
||||||
|
|
||||||
:plugins [[lein-cljsbuild "1.0.4"]
|
:plugins [[lein-cljsbuild "1.0.4"]
|
||||||
[lein-figwheel "0.2.3-SNAPSHOT"]]
|
[lein-figwheel "0.2.3-SNAPSHOT"]]
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
(defproject todomvc-re-frame "0.3.0"
|
(defproject todomvc-re-frame "0.3.1"
|
||||||
:dependencies [[org.clojure/clojure "1.6.0"]
|
:dependencies [[org.clojure/clojure "1.6.0"]
|
||||||
[org.clojure/clojurescript "0.0-2816"]
|
[org.clojure/clojurescript "0.0-2816"]
|
||||||
[reagent "0.5.0"]
|
[reagent "0.5.0"]
|
||||||
[re-frame "0.3.0"]
|
[re-frame "0.3.1"]
|
||||||
[secretary "1.2.1"]]
|
[secretary "1.2.1"]]
|
||||||
|
|
||||||
:plugins [[lein-cljsbuild "1.0.4"]]
|
:plugins [[lein-cljsbuild "1.0.4"]]
|
||||||
|
@ -7,56 +7,44 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn filter-fn-for
|
(defn filter-fn-for
|
||||||
[showing-kw]
|
[showing-kw]
|
||||||
(case showing-kw
|
(case showing-kw
|
||||||
:active (complement :done)
|
:active (complement :done)
|
||||||
:done :done
|
:done :done
|
||||||
:all identity))
|
:all identity))
|
||||||
|
|
||||||
|
|
||||||
(defn completed-count
|
(defn completed-count
|
||||||
"return the count of todos for which :done is true"
|
"return the count of todos for which :done is true"
|
||||||
[todos]
|
[todos]
|
||||||
(count (filter :done (vals todos))))
|
(count (filter :done (vals todos))))
|
||||||
|
|
||||||
|
|
||||||
;; -- Subscription handlers and registration ---------------------------------
|
;; -- Subscription handlers and registration ---------------------------------
|
||||||
|
|
||||||
(def register-sub-2 (fn [a b c])) ;; XXXremove
|
(register-sub
|
||||||
(def fetch (fn [a])) ;; XXXremove
|
|
||||||
|
|
||||||
(register-sub-2
|
|
||||||
:todos ;; usage: (subscribe [:todos])
|
:todos ;; usage: (subscribe [:todos])
|
||||||
(fetch :todos)
|
(fn [db _]
|
||||||
(fn [todos _]
|
(reaction (vals (:todos @db)))))
|
||||||
(vals todos)))
|
|
||||||
|
|
||||||
(register-sub-2
|
(register-sub
|
||||||
:visible-todos
|
:visible-todos
|
||||||
[(fetch :todos) (fetch :showing)]
|
(fn [db _]
|
||||||
(fn [todos showing _]
|
(reaction (let [filter-fn (filter-fn-for (:showing @db))
|
||||||
(filter (filter-fn-for showing) (vals todos))))
|
todos (vals (:todos @db))]
|
||||||
|
(filter filter-fn todos)))))
|
||||||
|
|
||||||
(register-sub-2
|
(register-sub
|
||||||
:completed-count
|
:completed-count
|
||||||
(fetch :todos)
|
(fn [db _]
|
||||||
(fn [todos _]
|
(reaction (completed-count (:todos @db)))))
|
||||||
(completed-count todos)))
|
|
||||||
|
|
||||||
(register-sub-2
|
(register-sub
|
||||||
:footer-stats
|
:footer-stats
|
||||||
[(fetch :todos) (fetch :showing)]
|
(fn [db _]
|
||||||
(fn [todos showing _]
|
(reaction
|
||||||
(let [completed-count (completed-count todos)
|
(let [todos (:todos @db)
|
||||||
active-count (- (count todos) completed-count)]
|
completed-count (completed-count todos)
|
||||||
[active-count completed-count showing]))) ;; tuple
|
active-count (- (count todos) completed-count)
|
||||||
|
showing (:showing @db)]
|
||||||
|
[active-count completed-count showing])))) ;; tuple
|
||||||
;; So [:todos :showing] is the same as [(pull [:todos]) (from [:showing])]
|
|
||||||
;; a keyword or vector is wrapped in "from"
|
|
||||||
;; a fucntion is called with 'app-db' and 'v'
|
|
||||||
|
|
||||||
;; What about the base case: no accessors
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
(defproject re-frame "0.4.0.SNAPSHOT"
|
(defproject re-frame "0.3.1"
|
||||||
:description "A Clojurescript MVC-like Framework For Writing SPAs Using Regent."
|
:description "A Clojurescript MVC-like Framework For Writing SPAs Using Regent."
|
||||||
:url "https://github.com/Day8/re-frame.git"
|
:url "https://github.com/Day8/re-frame.git"
|
||||||
:license {:name "MIT"}
|
:license {:name "MIT"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user