mirror of https://github.com/status-im/reagent.git
Include size of cached reactions in tests
This commit is contained in:
parent
d476222abb
commit
28d454ece9
|
@ -5,6 +5,7 @@
|
|||
[reagent.debug :refer-macros [dbg log warn dev?]]))
|
||||
|
||||
(declare ^:dynamic *ratom-context*)
|
||||
(defonce cached-reactions {})
|
||||
|
||||
(defn ^boolean reactive? []
|
||||
(some? *ratom-context*))
|
||||
|
@ -15,7 +16,9 @@
|
|||
|
||||
(defonce -running (clojure.core/atom 0))
|
||||
|
||||
(defn running [] @-running)
|
||||
(defn running []
|
||||
(+ @-running
|
||||
(count cached-reactions)))
|
||||
|
||||
(defn capture-derefed [f obj]
|
||||
(set! (.-cljsCaptured obj) nil)
|
||||
|
@ -118,8 +121,6 @@
|
|||
|
||||
(declare make-reaction)
|
||||
|
||||
(defonce cached-reactions {})
|
||||
|
||||
(defn- cached-reaction [f key obj destroy]
|
||||
(if-some [r (get cached-reactions key)]
|
||||
(-deref r)
|
||||
|
|
|
@ -193,19 +193,19 @@
|
|||
:on-dispose #(reset! disposed-cns true))]
|
||||
@cns
|
||||
(is (= @res 2))
|
||||
(is (= (+ 5 runs) (running)))
|
||||
(is (= (+ 6 runs) (running)))
|
||||
(is (= @count-b 1))
|
||||
(is (= {:a 0 :b 0} @a-base))
|
||||
(reset! a -1)
|
||||
(is (= @res 1))
|
||||
(is (= @disposed nil))
|
||||
(is (= @count-b 2))
|
||||
(is (= (+ 5 runs) (running)) "still running")
|
||||
(is (= (+ 6 runs) (running)) "still running")
|
||||
(is (= {:a -1 :b 0} @a-base))
|
||||
(reset! a 2)
|
||||
(is (= @res 1))
|
||||
(is (= @disposed true))
|
||||
(is (= (+ 3 runs) (running)) "less running count")
|
||||
(is (= (+ 4 runs) (running)) "less running count")
|
||||
(is (= {:a 2 :b 0} @a-base))
|
||||
|
||||
(reset! disposed nil)
|
||||
|
|
Loading…
Reference in New Issue