mirror of
https://github.com/status-im/reagent.git
synced 2025-01-13 21:34:29 +00:00
Fix bug where auto-run reactions might not re-run
This commit is contained in:
parent
fea897eca1
commit
891609cd1a
@ -19,7 +19,6 @@
|
||||
|
||||
(defn captured [obj]
|
||||
(let [c (.-cljsCaptured obj)]
|
||||
(set! (.-cljsCaptured obj) nil)
|
||||
c))
|
||||
|
||||
(defn- notify-deref-watcher! [derefable]
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user