On Friday, July 18, 2014 2:02:54 AM UTC+10, Jarppe Länsiö wrote: > I have this same problem. I thought multimethods would be great way to render > different views in simple page app, so I wrote something like this: > > (def app-state {:view :login}) > > (defmulti render-view (fn [app owner] (:view app))) > > (defmethod render-view :login [app owner] > (om/component > ... > > (defmethod render-view :foo [app owner] > (om/component > ... > > (om/root > render-view > app-state > {:target (js/document.getElementById "app")}) > > This works, except that the local state does not work. I guess this is same > problem Feng describes? > > What would be a work around? Shoud I just have a something like this: > > (om/root > (fn [app owner] > (condp = (:view app) > :login (login-view app) > ...one line for each view..
Using conditionals seems to be the easiest way to avoid state problems in multimethod. My guess is, multimethod should be avoided if a component has local state. Om's tutorial only used multimethods for components that do not have local state, just that it doesn't discuss potential issues and limitations of multimethod. With the limitation on mount/unmount that Daniel pointed out, I think it's easiest to not use multimethods. -- 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 clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at http://groups.google.com/group/clojurescript.