Fix bug where auto-run reactions might not re-run

This commit is contained in:
Juan Patten 2015-10-28 23:17:51 -06:00
parent fea897eca1
commit 891609cd1a
2 changed files with 20 additions and 1 deletions

View File

@ -19,7 +19,6 @@
(defn captured [obj]
(let [c (.-cljsCaptured obj)]
(set! (.-cljsCaptured obj) nil)
c))
(defn- notify-deref-watcher! [derefable]

View File

@ -238,6 +238,26 @@
(is (= @b 6))
(is (= runs (running)))))
(deftest reset-in-reaction
(let [runs (running)
state (rv/atom {})
c1 (reaction (get-in @state [:data :a]))
c2 (reaction (get-in @state [:data :b]))
rxn (rv/make-reaction
#(let [cc1 @c1
cc2 @c2]
(swap! state assoc :derived (+ cc1 cc2))
nil)
:auto-run true)]
@rxn
(is (= (:derived @state) 0))
(swap! state assoc :data {:a 1, :b 2})
(is (= (:derived @state) 3))
(swap! state assoc :data {:a 11, :b 22})
(is (= (:derived @state) 33))
(dispose rxn)
(is (= runs (running)))))
;; (deftest catching
;; (let [runs (running)
;; a (rv/atom false)