mirror of https://github.com/status-im/reagent.git
on-dispose should always be called in Reaction
This commit is contained in:
parent
897b766624
commit
6f448f296f
|
@ -121,7 +121,7 @@
|
||||||
(dissoc cached-reactions key))
|
(dissoc cached-reactions key))
|
||||||
(when (some? obj)
|
(when (some? obj)
|
||||||
(set! (.-reaction obj) nil))
|
(set! (.-reaction obj) nil))
|
||||||
(when (some-> destroy .-destroy)
|
(when (some-> destroy .-destroy some?)
|
||||||
(.destroy destroy))))
|
(.destroy destroy))))
|
||||||
v (-deref r)]
|
v (-deref r)]
|
||||||
(set! cached-reactions (assoc cached-reactions key r))
|
(set! cached-reactions (assoc cached-reactions key r))
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
(set! (.-reaction obj) r))
|
(set! (.-reaction obj) r))
|
||||||
v)
|
v)
|
||||||
(let [res (f)]
|
(let [res (f)]
|
||||||
(when (some-> destroy .-destroy)
|
(when (some-> destroy .-destroy some?)
|
||||||
(.destroy destroy))
|
(.destroy destroy))
|
||||||
res))))
|
res))))
|
||||||
|
|
||||||
|
@ -401,7 +401,9 @@
|
||||||
IDeref
|
IDeref
|
||||||
(-deref [this]
|
(-deref [this]
|
||||||
(-check-clean this)
|
(-check-clean this)
|
||||||
(if (and (nil? auto-run) (nil? *ratom-context*))
|
(if (and (nil? *ratom-context*)
|
||||||
|
(nil? auto-run))
|
||||||
|
(do
|
||||||
(when-not (== dirtyness clean)
|
(when-not (== dirtyness clean)
|
||||||
(let [oldstate state
|
(let [oldstate state
|
||||||
newstate (f)]
|
newstate (f)]
|
||||||
|
@ -409,6 +411,9 @@
|
||||||
(when (and (some? watches)
|
(when (and (some? watches)
|
||||||
(not= oldstate newstate))
|
(not= oldstate newstate))
|
||||||
(-notify-watches this oldstate newstate))))
|
(-notify-watches this oldstate newstate))))
|
||||||
|
(when (and (some? on-dispose)
|
||||||
|
(nil? watches))
|
||||||
|
(on-dispose)))
|
||||||
(do
|
(do
|
||||||
(notify-deref-watcher! this)
|
(notify-deref-watcher! this)
|
||||||
(when-not (== dirtyness clean)
|
(when-not (== dirtyness clean)
|
||||||
|
|
Loading…
Reference in New Issue