Fix cursor bug

Cursor wasn't updated when changing both the cursor and an
underlying atom at once.
This commit is contained in:
Dan Holmsand 2015-05-25 21:31:43 +02:00
parent 60d99c44fe
commit cdd3c851a0
2 changed files with 17 additions and 1 deletions

View File

@ -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)))

View File

@ -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)))