diff --git a/project.clj b/project.clj index 10f06a3..2c78928 100644 --- a/project.clj +++ b/project.clj @@ -47,6 +47,7 @@ {:compiler {:optimizations :advanced :elide-asserts true :pretty-print false + ;; :pseudo-names true :output-dir "target/client"}}}}}] :prod-test [:test :prod] diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index 1ac4dff..4fa47f5 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -211,12 +211,17 @@ (when (== ra.dirty? maybe-dirty) (set! ra.norun? true) (doseq [w ra.watching] - (when (reaction? w) + (when (and (reaction? w) + (not (identical? (.-dirty? w) clean))) (-deref w))) (set! ra.norun? false) (when (== ra.dirty? maybe-dirty) (set! ra.dirty? clean)))) +(defn- ra-run-check [ra] + (binding [*ratom-context* (js-obj)] + (ra-check-clean ra))) + (defn- ra-handle-change [ra sender oldval newval] (when ra.active? (let [old-dirty ra.dirty?] @@ -229,8 +234,7 @@ (do ;; FIXME: is this correct? (when (== ra.dirty? maybe-dirty) - (binding [*ratom-context* (js-obj)] - (ra-check-clean ra))) + (ra-run-check ra)) (when-not (== ra.dirty? clean) ((or ra.auto-run run) ra))) (when (== old-dirty clean)