From be7bb6954807314e7c63fe18ba9504799732ce98 Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Mon, 31 Aug 2015 10:59:59 +0200 Subject: [PATCH] wip --- src/reagent/ratom.cljs | 24 +++++++++++++----------- test/reagenttest/testreagent.cljs | 1 + 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index ad6d3b1..f658645 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -247,17 +247,19 @@ IComputedImpl (-handle-change [this sender oldval newval] (when active? - (set! dirty? (max dirty? - (if (identical? oldval newval) - maybe-dirty is-dirty))) - (if auto-run - (do - ;; FIXME: is this correct? - (binding [*ratom-context* this] - (-check-clean this)) - (when (> dirty? clean) - ((or auto-run run) this))) - (-notify-watches this state state))) + (let [old-dirty dirty?] + (set! dirty? (max dirty? + (if (identical? oldval newval) + maybe-dirty is-dirty))) + (if auto-run + (do + ;; FIXME: is this correct? + (when (== dirty? maybe-dirty) + (binding [*ratom-context* (js-obj)] + (-check-clean this))) + (when-not (== 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)) diff --git a/test/reagenttest/testreagent.cljs b/test/reagenttest/testreagent.cljs index bad298a..45d3d66 100644 --- a/test/reagenttest/testreagent.cljs +++ b/test/reagenttest/testreagent.cljs @@ -119,6 +119,7 @@ (reset! val 1) (reset! val 2) (reset! val 1) + (is (= 1 @ran)) (r/flush) (is (found-in #"val 1" div)) (is (= 2 @ran))