The first argument to om/root is a function, the second argument is the
application state. Ones a function, the other is state.

That function, when called (typically by om/build, but in the case of
om/root, its called internally) returns an instance of the Om component.
You never use this instance directly, its handled by Om. This "constructor"
function takes a number of arguments (but they are all optional and can be
omitted if you don't need them). In left to right order:

1. A cursor into the application state. In the case of the root component,
this is basically a cursor version of all of app-state.

2. The so-called "owner", which is basically the React component that makes
up the Om component (ie what Om components look like from react's
perspective). This is needed by various Om functions to access component
properties (eg local state).

3. The "opts" map, which is a map of static options. One really should only
pass static constant non-changing data here because changes are NOT seen by
the component once the component is mounted.

Hope that clarifies things.

On Thu Dec 11 2014 at 6:42:20 PM gvim <[email protected]> wrote:

> I'm finding the basic Om tutorial at
> github.com/swannodette/om/wiki/Basic-Tutorial confusing:
>
> (ns om-tut.core
>    (:require [om.core :as om :include-macros true]
>              [om.dom :as dom :include-macros true]))
>
> (enable-console-print!)
>
> (def app-state (atom {:text "Hello world!"}))
>
> (om/root
>    (fn [app owner]
>      (reify om/IRender
>        (render [_]
>          (dom/h1 nil (:text app)))))
>    app-state
>    {:target (. js/document (getElementById "app"))})
>
> "... The first argument is a function that takes the application state
> data and the backing React component, here called owner.
> ..... The second argument is the application state atom ....."
>
> What's the difference? Which is which? The distinction is lost on me as
> app isn't referred to elsewhere and app-state also contains application
> state data.
>
> gvim
>
>
>
>
>
> --
> 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