allow for defvc components to include doc comments and attribute maps
just like reagent components would be able to do when defined with defn
This commit is contained in:
parent
20be582a1a
commit
d5e421de52
|
@ -11,8 +11,22 @@
|
||||||
components defined with defvc will automatically manage subscribing
|
components defined with defvc will automatically manage subscribing
|
||||||
and unsubscribing to views as the view signatures passed to any
|
and unsubscribing to views as the view signatures passed to any
|
||||||
view-cursor calls change across the lifetime of this component."
|
view-cursor calls change across the lifetime of this component."
|
||||||
[component-name args & body]
|
{:arglists '([component-name doc-string? attr-map? [params*] body])}
|
||||||
`(defn ~component-name []
|
[component-name & decl]
|
||||||
|
(let [attr-map (if (string? (first decl))
|
||||||
|
{:doc (first decl)}
|
||||||
|
{})
|
||||||
|
decl (if (string? (first decl))
|
||||||
|
(next decl)
|
||||||
|
decl)
|
||||||
|
attr-map (if (map? (first decl))
|
||||||
|
(conj attr-map (first decl))
|
||||||
|
attr-map)
|
||||||
|
decl (if (map? (first decl))
|
||||||
|
(next decl)
|
||||||
|
decl)
|
||||||
|
[args & body] decl]
|
||||||
|
`(defn ~component-name ~attr-map []
|
||||||
(reagent.core/create-class
|
(reagent.core/create-class
|
||||||
{:component-will-mount
|
{:component-will-mount
|
||||||
(fn [this#]
|
(fn [this#]
|
||||||
|
@ -39,4 +53,4 @@
|
||||||
|
|
||||||
:component-function
|
:component-function
|
||||||
(fn ~args
|
(fn ~args
|
||||||
~@body)})))
|
~@body)}))))
|
||||||
|
|
Loading…
Reference in a new issue