To answer your question, I did a little digging :)

I'm sure David can give you more details, but from browsing the code, I see
that on render, the components state gets *swap!*'d with itself:
https://github.com/swannodette/om/blob/master/src/om/core.cljs#L681
(*this*is passed into setup as
*state*, which is created from app-state:
https://github.com/swannodette/om/blob/master/src/om/core.cljs#L735) It
does this because internally, it uses a watch to call render:
https://github.com/swannodette/om/blob/master/src/om/core.cljs#L753

This means that your app-state watch will be triggered every time the
component is rendered.


On 4 May 2014 17:53, Roger Gilliar <[email protected]> wrote:

> Thanks for suggestions it is working now. The only thing I do not
> understand is
>
> why the following code:
>
> (defn- handle-change [e owner]
>   (let [input  (.. e -target -value)]
>     (om/set-state! owner :value input)))
>
> triggers the watch expression:
>
> (add-watch app-state :history
>            (fn [_ _ _ n]
>              (println @app-state)))
>
> app-state is my global application state and owner is a component with a
> local state.
>
> --
> 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