Now almost working

This commit is contained in:
Dan Holmsand 2015-08-31 10:39:17 +02:00
parent 043c8b0dee
commit 6c345db29e
3 changed files with 21 additions and 13 deletions

View File

@ -195,7 +195,8 @@
(defprotocol IComputedImpl
(-update-watching [this derefed])
(-handle-change [k sender oldval newval])
(-peek-at [this]))
(-peek-at [this])
(-check-clean [this]))
(def clean 0)
(def maybe-dirty 1)
@ -250,8 +251,12 @@
(if (identical? oldval newval)
maybe-dirty is-dirty)))
(if auto-run
(when (> dirty? clean)
((or auto-run run) this))
(do
;; FIXME: is this correct?
(binding [*ratom-context* this]
(-check-clean this))
(when (> dirty? clean)
((or auto-run run) this)))
(-notify-watches this state state)))
;; (when (and active? (not (identical? oldval newval)))
;; (set! dirty? is-dirty)
@ -273,6 +278,16 @@
(binding [*ratom-context* nil]
(-deref this))))
(-check-clean [this]
(when (== dirty? maybe-dirty)
(let [oldauto auto-run]
(set! auto-run nil)
(doseq [w watching]
(-deref w))
(set! auto-run oldauto))
(when (== dirty? maybe-dirty)
(set! dirty? clean))))
IRunnable
(run [this]
(let [oldstate state
@ -290,14 +305,7 @@
IDeref
(-deref [this]
(when (== dirty? maybe-dirty)
(let [oldauto auto-run]
(set! auto-run nil)
(doseq [w watching]
(-deref w))
(set! auto-run oldauto))
(when (== dirty? maybe-dirty)
(set! dirty? clean)))
(-check-clean this)
(if (or auto-run (some? *ratom-context*))
(do
(notify-deref-watcher! this)

View File

@ -11,7 +11,7 @@
(rv/running))
(defn dispose [v] (rv/dispose! v))
(def testite 1)
(def testite 10)
(deftest basic-cursor
(let [runs (running)

View File

@ -8,7 +8,7 @@
(set! rv/debug true)
(rv/running))
(def testite 1)
(def testite 10)
(defn dispose [v]
(rv/dispose! v))