Currently in Om the component function is the type identifier for a
component. Your multimethod needs to return the function to construct the
component instead of invoking it directly.

David


On Mon, Apr 7, 2014 at 12:38 PM, Samuel Morello <[email protected]
> wrote:

> Hi,
>
> I have a problem to understand why the follwoing exmaple does not work.
>
>
> (def app-state (atom {:version "0.1.0"
>                                   :project-id nil}))
>
>
>
> ; main widget
> (defn app [app owner]
>   (reify
>     om/IRender
>     (render [_]
>       (html [:div.app-wrapper nil
>                 (om/build sidebar app)
>                 (om/build main app)]))))
>
>
>
> (defn main [app-state owner]
>   (reify
>     om/IRender
>     (render [_]
>       (html [:div.main-wrapper nil
>         (om/build entry-view app-state)]))))
>
>
>
> (defmulti entry-view (fn [app-state _]
>   (if (= (:project-id app-state) nil)
>     :empty
>     :exist)))
>
> (defmethod entry-view :empty
>   [app-state owner] (empty-view app-state owner))
>
> (defmethod entry-view :exist
>   [app-state owner] (project-view app-state owner))
>
>
>
> (defn empty-view [app-state owner]
>   (reify
>     om/IWillMount
>     (will-mount [_]
>       (prn "ok i will mount"))
>     om/IRender
>     (render [_]
>       (html [:div nil
>               [:h2 nil"Open an existing project"]]))))
>
>
>
> (defn project-view [app-state owner]
>   (reify
>     om/IWillMount
>     (will-mount [_]
>       (prn "why not me ?"))
>     om/IRender
>     (render [_]
>       (html [:div nil (str "project view: " (:project-id app-state))]))))
>
>
>
> At first the "ok i will mount" message is correctly printed in the console.
> But when i change the state.
> The project-view component is correctly rendered but the will-mount method
> does not print nothing
>
>
> Can someone explain me why ?
>
> Many thanks,
>
> Samuel
>
>
> --
> 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