From a12267308e5324ee19e1b40fa31e1eec5f6c25c7 Mon Sep 17 00:00:00 2001 From: mike-thompson-day8 Date: Fri, 17 Apr 2015 22:34:40 +1000 Subject: [PATCH] v0.3.1 --- CHANGES.md | 23 +++--------- examples/todomvc/src/todomvc/subs.cljs | 50 ++++++++++++++++---------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 84e5e76..2bcdf72 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,24 +1,12 @@ -## Planned for v0.4.0 - - - automatically wrap subscriptions in a `reaction` (removing the need for over - 10 keystrokes per handler!!). Just kidding there are better reasons than that. - - further develop the debugging story. - - modifiy todoMVC for new subscriptions approach - - document new sbscriptions approach - - move contents of README across to Wiki. Make Readme simpler and more pragmatic. - - produce a more fully featured todomvc (beyond the standard one), todomvc-with-extras - - use `enrich` to handle todo duplication - - add prismatic schema - - show testing - - show debug - - undo - +## v0.3.1 (2015-04-18) -### Other +Various small improvements and bug fixes: - - middleware anonymous functions given better names. Makes stack traces easier to understand. + - modest improves to simple example. Better comments, layout, etc. + - the anonymous functions in standard middleware now have meaningful + names, which makes stack traces easier to understand. - #24 - Fix missing paren in README - #31 - Fix list formatting in README - #32 - fix a broken wiki link @@ -29,7 +17,6 @@ ### Headline - - the middleware `after` and `enrich` now call the supplied function `f` with both `db` and `v` (previously just `db`). Because javascript is so forgiving about function arity, this change is backwards compatible. diff --git a/examples/todomvc/src/todomvc/subs.cljs b/examples/todomvc/src/todomvc/subs.cljs index 801a7e1..6c2f0f2 100644 --- a/examples/todomvc/src/todomvc/subs.cljs +++ b/examples/todomvc/src/todomvc/subs.cljs @@ -22,29 +22,41 @@ ;; -- Subscription handlers and registration --------------------------------- -(register-sub +(def register-sub-2 (fn [a b c])) ;; XXXremove +(def fetch (fn [a])) ;; XXXremove + +(register-sub-2 :todos ;; usage: (subscribe [:todos]) - (fn [db _] - (reaction (vals (:todos @db))))) + (fetch :todos) + (fn [todos _] + (vals todos))) -(register-sub +(register-sub-2 :visible-todos - (fn [db _] - (reaction (let [filter-fn (filter-fn-for (:showing @db)) - todos (vals (:todos @db))] - (filter filter-fn todos))))) + [(fetch :todos) (fetch :showing)] + (fn [todos showing _] + (filter (filter-fn-for showing) (vals todos)))) -(register-sub +(register-sub-2 :completed-count - (fn [db _] - (reaction (completed-count (:todos @db))))) + (fetch :todos) + (fn [todos _] + (completed-count todos))) -(register-sub +(register-sub-2 :footer-stats - (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 + [(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 + + +