Get rid of form-2 subs in defview
This commit is contained in:
parent
5aa33fc9c0
commit
f9df0f367f
|
@ -2,9 +2,8 @@
|
||||||
(:require [clojure.walk :as w]))
|
(:require [clojure.walk :as w]))
|
||||||
|
|
||||||
(defn atom? [sub]
|
(defn atom? [sub]
|
||||||
(or (vector? sub)
|
(and (seq sub)
|
||||||
(and (seq sub)
|
(#{`reagent.core/atom} (first sub))))
|
||||||
(#{`reagent.core/atom} (first sub)))))
|
|
||||||
|
|
||||||
(defn walk-sub [sub form->sym]
|
(defn walk-sub [sub form->sym]
|
||||||
(if (coll? sub)
|
(if (coll? sub)
|
||||||
|
@ -24,13 +23,16 @@
|
||||||
(map (fn [{:keys [form sym]}]
|
(map (fn [{:keys [form sym]}]
|
||||||
[form sym]))
|
[form sym]))
|
||||||
(into {}))]
|
(into {}))]
|
||||||
[(mapcat (fn [{:keys [form sym sub]}]
|
[(mapcat (fn [{:keys [form sub]}]
|
||||||
(if (vector? sub)
|
(when-not (vector? sub)
|
||||||
[sym `(re-frame.core/subscribe ~(walk-sub sub form->sym))]
|
|
||||||
[form (walk-sub sub form->sym)]))
|
[form (walk-sub sub form->sym)]))
|
||||||
pairs)
|
pairs)
|
||||||
(apply concat (keep (fn [{:keys [sym form sub]}]
|
(apply concat (keep (fn [{:keys [sym form sub]}]
|
||||||
(when (atom? sub)
|
(cond
|
||||||
|
(vector? sub)
|
||||||
|
[form `(deref (re-frame.core/subscribe ~(walk-sub sub form->sym)))]
|
||||||
|
|
||||||
|
(atom? sub)
|
||||||
[form `(deref ~sym)]))
|
[form `(deref ~sym)]))
|
||||||
pairs))]))
|
pairs))]))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue