diff --git a/src/reagent/ratom.cljs b/src/reagent/ratom.cljs index 49c7206..9d7a759 100644 --- a/src/reagent/ratom.cljs +++ b/src/reagent/ratom.cljs @@ -153,8 +153,10 @@ (Monitor. #(apply f args) [f args] nil)) (defn monitor! [f & args] - (make-reaction #(deref (apply monitor f args)) - :auto-run :async)) + (let [r (make-reaction #(deref (apply monitor f args)) + :auto-run :async)] + @r + r)) ;;; cursor @@ -457,8 +459,6 @@ runner on-set on-dispose nocache)] (when-not (nil? derefed) (-update-watching reaction derefed)) - (when (keyword-identical? auto-run :async) - (enqueue reaction)) reaction)) diff --git a/test/reagenttest/testmonitor.cljs b/test/reagenttest/testmonitor.cljs index 42be9e1..49704f2 100644 --- a/test/reagenttest/testmonitor.cljs +++ b/test/reagenttest/testmonitor.cljs @@ -59,8 +59,6 @@ res (monitor resf) const (rv/monitor! #(reset! out @res))] - (is (= @count 0)) - (sync) (is (= @count 1) "constrain ran") (is (= @out 5)) (reset! start 1) diff --git a/test/reagenttest/testratomasync.cljs b/test/reagenttest/testratomasync.cljs index 03fd473..cdf2377 100644 --- a/test/reagenttest/testratomasync.cljs +++ b/test/reagenttest/testratomasync.cljs @@ -8,7 +8,7 @@ (set! rv/debug true) (rv/running)) -(def testite 10) +(def testite 1) (defn dispose [v] (rv/dispose! v)) @@ -32,7 +32,7 @@ const (ar (fn [] (reset! out @res)))] (is (= @count 0)) - (sync) + @const (is (= @count 1) "constrain ran") (is (= @out 2)) (reset! start 1) @@ -85,7 +85,7 @@ ;;update the counter (swap! !counter inc)))] (is (= 0 @!counter)) - (sync) + @co (is (= 1 @!counter) "Constraint run on init") (reset! !signal "foo") (sync) @@ -94,7 +94,7 @@ (dispose co)) (let [!x (rv/atom 0) !co (rv/make-reaction #(inc @!x) :auto-run :async)] - (sync) + @!co (is (= 1 @!co) "CO has correct value on first deref") (swap! !x inc) (sync) @@ -126,7 +126,7 @@ (reset! a -1) (is (= @b-changed 1)) - (sync) + @res (is (= @b-changed 2)) (is (= @c-changed 0)) @@ -166,7 +166,7 @@ res (rv/atom 0) cs (ar #(reset! res @d))] - (sync) + @cs (is (= @res "1")) (dispose cs)) ;; should be broken according to https://github.com/lynaghk/reflex/issues/1 @@ -184,7 +184,7 @@ res (rv/atom 0)] (is (= @d [1 -1])) (let [e (ar #(reset! res @d))] - (sync) + @e (is (= @res [1 -1])) (dispose e)) (dispose d)) @@ -208,7 +208,7 @@ cns (rv/make-reaction #(reset! res @c) :auto-run :async :on-dispose #(reset! disposed-cns true))] - (sync) + @cns (is (= @res 2)) (is (= (+ 4 runs) (running))) (is (= @count-b 1)) @@ -281,7 +281,7 @@ (set! rv/silent true) (is (= @catch-count 0)) (reset! a false) - (sync) + @c (is (= @catch-count 0)) (reset! a true) (is (= @catch-count 0))