From 1782ff1832c8299c4c51ce483c748c3efd40fece Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Mon, 31 Aug 2015 10:05:53 +0200 Subject: [PATCH] wip - not working --- src/reagent/ratom.cljs | 15 ++++++++++++--- test/reagenttest/testcursor.cljs | 6 ++++-- test/reagenttest/testratom.cljs | 6 ++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index 55fa5b8..a9d7440 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -245,9 +245,18 @@ IComputedImpl (-handle-change [this sender oldval newval] - (when (and active? (not (identical? oldval newval))) - (set! dirty? is-dirty) - ((or auto-run run) this))) + (when active? + (set! dirty? (max dirty? + (if (identical? oldval newval) + maybe-dirty is-dirty))) + (if auto-run + (when (> dirty? clean) + ((or auto-run run) this)) + (-notify-watches this state state))) + ;; (when (and active? (not (identical? oldval newval))) + ;; (set! dirty? is-dirty) + ;; ((or auto-run run) this)) + ) (-update-watching [this derefed] (doseq [w derefed] diff --git a/test/reagenttest/testcursor.cljs b/test/reagenttest/testcursor.cljs index 77fa32f..a3d14de 100644 --- a/test/reagenttest/testcursor.cljs +++ b/test/reagenttest/testcursor.cljs @@ -11,6 +11,8 @@ (rv/running)) (defn dispose [v] (rv/dispose! v)) +(def testite 1) + (deftest basic-cursor (let [runs (running) start-base (rv/atom {:a {:b {:c 0}}}) @@ -85,7 +87,7 @@ (deftest test-unsubscribe - (dotimes [x 10] + (dotimes [x testite] (let [runs (running) a-base (rv/atom {:test {:unsubscribe 0 :value 42}}) a (r/cursor a-base [:test :unsubscribe]) @@ -171,7 +173,7 @@ (is (= runs (running))))) (deftest test-dispose - (dotimes [x 10] + (dotimes [x testite] (let [runs (running) a-base (rv/atom {:a 0 :b 0}) a (r/cursor a-base [:a]) diff --git a/test/reagenttest/testratom.cljs b/test/reagenttest/testratom.cljs index f96a8fc..2258e0d 100644 --- a/test/reagenttest/testratom.cljs +++ b/test/reagenttest/testratom.cljs @@ -8,6 +8,8 @@ (set! rv/debug true) (rv/running)) +(def testite 1) + (defn dispose [v] (rv/dispose! v)) @@ -89,7 +91,7 @@ (deftest test-unsubscribe - (dotimes [x 10] + (dotimes [x testite] (let [runs (running) a (rv/atom 0) a1 (reaction (inc @a)) @@ -166,7 +168,7 @@ (is (= runs (running))))) (deftest test-dispose - (dotimes [x 10] + (dotimes [x testite] (let [runs (running) a (rv/atom 0) disposed (rv/atom nil)