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"]
|
||||
[org.clojure/clojurescript "0.0-2816"]
|
||||
[reagent "0.5.0"]
|
||||
[re-frame "0.3.0"]
|
||||
[figwheel "0.2.3-SNAPSHOT"]]
|
||||
[re-frame "0.3.1"]
|
||||
[figwheel "0.2.6"]]
|
||||
|
||||
:plugins [[lein-cljsbuild "1.0.4"]
|
||||
[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"]
|
||||
[org.clojure/clojurescript "0.0-2816"]
|
||||
[reagent "0.5.0"]
|
||||
[re-frame "0.3.0"]
|
||||
[re-frame "0.3.1"]
|
||||
[secretary "1.2.1"]]
|
||||
|
||||
:plugins [[lein-cljsbuild "1.0.4"]]
|
||||
|
@ -7,56 +7,44 @@
|
||||
|
||||
|
||||
(defn filter-fn-for
|
||||
[showing-kw]
|
||||
(case showing-kw
|
||||
:active (complement :done)
|
||||
:done :done
|
||||
:all identity))
|
||||
[showing-kw]
|
||||
(case showing-kw
|
||||
:active (complement :done)
|
||||
:done :done
|
||||
:all identity))
|
||||
|
||||
|
||||
(defn completed-count
|
||||
"return the count of todos for which :done is true"
|
||||
[todos]
|
||||
(count (filter :done (vals todos))))
|
||||
"return the count of todos for which :done is true"
|
||||
[todos]
|
||||
(count (filter :done (vals todos))))
|
||||
|
||||
|
||||
;; -- Subscription handlers and registration ---------------------------------
|
||||
|
||||
(def register-sub-2 (fn [a b c])) ;; XXXremove
|
||||
(def fetch (fn [a])) ;; XXXremove
|
||||
|
||||
(register-sub-2
|
||||
(register-sub
|
||||
:todos ;; usage: (subscribe [:todos])
|
||||
(fetch :todos)
|
||||
(fn [todos _]
|
||||
(vals todos)))
|
||||
(fn [db _]
|
||||
(reaction (vals (:todos @db)))))
|
||||
|
||||
(register-sub-2
|
||||
(register-sub
|
||||
:visible-todos
|
||||
[(fetch :todos) (fetch :showing)]
|
||||
(fn [todos showing _]
|
||||
(filter (filter-fn-for showing) (vals todos))))
|
||||
(fn [db _]
|
||||
(reaction (let [filter-fn (filter-fn-for (:showing @db))
|
||||
todos (vals (:todos @db))]
|
||||
(filter filter-fn todos)))))
|
||||
|
||||
(register-sub-2
|
||||
(register-sub
|
||||
:completed-count
|
||||
(fetch :todos)
|
||||
(fn [todos _]
|
||||
(completed-count todos)))
|
||||
(fn [db _]
|
||||
(reaction (completed-count (:todos @db)))))
|
||||
|
||||
(register-sub-2
|
||||
(register-sub
|
||||
:footer-stats
|
||||
[(fetch :todos) (fetch :showing)]
|
||||
(fn [todos showing _]
|
||||
(let [completed-count (completed-count todos)
|
||||
active-count (- (count todos) completed-count)]
|
||||
[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
|
||||
|
||||
|
||||
|
||||
(fn [db _]
|
||||
(reaction
|
||||
(let [todos (:todos @db)
|
||||
completed-count (completed-count todos)
|
||||
active-count (- (count todos) completed-count)
|
||||
showing (:showing @db)]
|
||||
[active-count completed-count showing])))) ;; tuple
|
||||
|
@ -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."
|
||||
:url "https://github.com/Day8/re-frame.git"
|
||||
:license {:name "MIT"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user