mirror of https://github.com/status-im/reagent.git
Simplify with-let even more
This commit is contained in:
parent
b17ff0a576
commit
6a206eccf3
|
@ -23,6 +23,12 @@
|
||||||
(= 'finally (first fin)))
|
(= 'finally (first fin)))
|
||||||
[(butlast body) `(fn [] ~@(rest fin))]
|
[(butlast body) `(fn [] ~@(rest fin))]
|
||||||
[body nil]))
|
[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)]
|
asserting (if *assert* true false)]
|
||||||
`(let [~v (reagent.ratom/with-let-value ~k)]
|
`(let [~v (reagent.ratom/with-let-value ~k)]
|
||||||
(when ~asserting
|
(when ~asserting
|
||||||
|
@ -35,10 +41,6 @@
|
||||||
(aset ~v 0 (let ~bindings
|
(aset ~v 0 (let ~bindings
|
||||||
(fn []
|
(fn []
|
||||||
(let [res# (do ~@forms)]
|
(let [res# (do ~@forms)]
|
||||||
(when-some [destroy# ~destroy]
|
~add-destroy
|
||||||
(if (reagent.ratom/reactive?)
|
|
||||||
(when (< (alength ~v) 2)
|
|
||||||
(aset ~v 1 destroy#))
|
|
||||||
(destroy#)))
|
|
||||||
res#)))))
|
res#)))))
|
||||||
((aget ~v 0)))))
|
((aget ~v 0)))))
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
(dissoc cached-reactions key))
|
(dissoc cached-reactions key))
|
||||||
(when (some? obj)
|
(when (some? obj)
|
||||||
(set! (.-reaction obj) nil))
|
(set! (.-reaction obj) nil))
|
||||||
(when-not (nil? destroy)
|
(when (some? destroy)
|
||||||
(destroy x))
|
(destroy x))
|
||||||
nil))
|
nil))
|
||||||
v (-deref r)]
|
v (-deref r)]
|
||||||
|
|
Loading…
Reference in New Issue