mirror of https://github.com/status-im/reagent.git
Fix cursor bug
Cursor wasn't updated when changing both the cursor and an underlying atom at once.
This commit is contained in:
parent
60d99c44fe
commit
cdd3c851a0
|
@ -240,7 +240,7 @@
|
||||||
|
|
||||||
IComputedImpl
|
IComputedImpl
|
||||||
(-handle-change [this sender oldval newval]
|
(-handle-change [this sender oldval newval]
|
||||||
(when (and active? (not dirty?) (not (identical? oldval newval)))
|
(when (and active? (not (identical? oldval newval)))
|
||||||
(set! dirty? true)
|
(set! dirty? true)
|
||||||
((or auto-run run) this)))
|
((or auto-run run) this)))
|
||||||
|
|
||||||
|
|
|
@ -426,3 +426,19 @@
|
||||||
(swap! a update-in [:b] inc)
|
(swap! a update-in [:b] inc)
|
||||||
(is (= 4 (swap! b inc)))
|
(is (= 4 (swap! b inc)))
|
||||||
(is (= 4 @b))))
|
(is (= 4 @b))))
|
||||||
|
|
||||||
|
(deftest test-double-reset
|
||||||
|
(let [a (r/atom {:foo {:active? false}})
|
||||||
|
c (r/cursor a [:foo])
|
||||||
|
f (fn []
|
||||||
|
(swap! c assoc :not-pristine true)
|
||||||
|
(swap! a update-in [:foo :active?] not))
|
||||||
|
spy (atom nil)
|
||||||
|
r (run!
|
||||||
|
(reset! spy (:active? @c)))]
|
||||||
|
(is (= @spy false))
|
||||||
|
(f)
|
||||||
|
(is (= @spy true))
|
||||||
|
(f)
|
||||||
|
(is (= @spy false))
|
||||||
|
(dispose r)))
|
||||||
|
|
Loading…
Reference in New Issue