Simplify with-let even more

This commit is contained in:
Dan Holmsand 2015-09-26 14:08:54 +02:00
parent b17ff0a576
commit 6a206eccf3
2 changed files with 8 additions and 6 deletions

View File

@ -23,6 +23,12 @@
(= 'finally (first fin)))
[(butlast body) `(fn [] ~@(rest fin))]
[body nil]))
add-destroy (when destroy
`(let [destroy# ~destroy]
(if (reagent.ratom/reactive?)
(when (< (alength ~v) 2)
(aset ~v 1 destroy#))
(destroy#))))
asserting (if *assert* true false)]
`(let [~v (reagent.ratom/with-let-value ~k)]
(when ~asserting
@ -35,10 +41,6 @@
(aset ~v 0 (let ~bindings
(fn []
(let [res# (do ~@forms)]
(when-some [destroy# ~destroy]
(if (reagent.ratom/reactive?)
(when (< (alength ~v) 2)
(aset ~v 1 destroy#))
(destroy#)))
~add-destroy
res#)))))
((aget ~v 0)))))

View File

@ -140,7 +140,7 @@
(dissoc cached-reactions key))
(when (some? obj)
(set! (.-reaction obj) nil))
(when-not (nil? destroy)
(when (some? destroy)
(destroy x))
nil))
v (-deref r)]