Ok I think I see the problems you are encountering. But I don't see how
this isn't solved by making the mutimethod return the right *function*.
It's a little bit more work and it means you'll have to repeat an argument
or two in your use of om.core/build but I think this is workable:

(om.core/build (view data) data ...)

Where view is a multimethod or protocol fn that returns the actual
component constructing function.

David


On Sun, Jan 19, 2014 at 9:27 PM, kovas boguta <[email protected]>wrote:

> There seems to be a problem with using multimethods (and presumably
> protocols) as the function passed to build.
>
> In particular, lifecycle methods will not be properly invoked after the
> initial render.
>
> The cause of the problem is that build identifies the "component type" as
> the function passed to build (as I understand it)
>
> In my case, I want to use a generic multimethod to map my data to specific
> components:
>
> (defmulti make (fn [x & args] (:tag x)))
>
> (defmethod make :component1 [x & args] (reify ....))
> (defmethod make :component2 [x & args] (reify ....))
>
> etc
>
> The result is that both component1 and component2 will end up with the
> same component type. Which means that if I swap component1 with component2
> in my app-state, render will be called but mount and unmount will not be,
> because React will think it was the same component.
>
> My workaround is to set! .-constructor of the object returned from build,
> but this is pretty ugly and requires additional bookkeeping, like creating
> unique objects to correspond to the tags.
>
> Is there a better way to do this?
>
>
> --
> 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