I would leverage multimethods. However nothing prevents you from
composing components and passing them via props - this approach is
popular in React.

David

On Mon, Nov 17, 2014 at 6:49 AM, Colin Yates <[email protected]> wrote:
> Hi all,
>
> I keep running into the really common use case (and seeing others running 
> into as well) of composing components.
>
> Quite simply, how is one supposed to compose components in om?
>
> In my particular use case I have a Header component which displays a title 
> and optionally a component describing a summary of what is being seen (which 
> is more than simple text). I want to do something like:
>
> (defn header [data owner]
>   (reify
>     om/IRender
>     (render [_]
>       (dom/div .....
>         (when optional-component) optional-component)))))
>
> It works if I put the component into either the header state or opts (e.g.
> (header data owner {:opts {:optional-component (om/build ...}}))
>
> but neither feel idiomatic. If I had to chose the lesser of two evils I would 
> chose :opts I guess.
>
> I did consider multi-methods, but this didn't feel particularly nice either.
>
> What am I missing as this doesn't seem to be an obscure use-case :)?
>
> --
> Note that posts from new members are moderated - please be patient with your 
> first post.
> ---
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to