Thank you all for discussing this topic.
My first feeling was that it is ok to have a component which fetches it state 
from the server while calling "init-state" so that the component itself is not 
dependent on the app-state of the cljs.

However, after reading all this and having read the wiki page about cursors I 
guess it makes more sense to load the inital data from the server when loading 
the cljs and then binding the om/root component to the cljs "app-state" and 
pass in the needed data via the cursors.

Best Regards,
Sven

Am Montag, 21. April 2014 12:44:25 UTC+2 schrieb David Nolen:
> Oops, sorry I read this too quickly. Yes this is the expected behavior and 
> not an issue at all.
> 
> 
> David
> 
> 
> 
> On Mon, Apr 21, 2014 at 3:44 AM, Sven Richter <[email protected]> wrote:
> 
> Hi,
> 
> 
> 
> while exploring OM I found out that render-state is called twice if 
> "init-state" changes the app-state.
> 
> This small snippet demonstrates this effect:
> 
> 
> 
> (def app-state (atom {:releases []}))
> 
> 
> 
> (defn div-list [data owner opts]
> 
>   (reify
> 
>     om/IInitState
> 
>     (init-state [_]
> 
>       (println "init state")
> 
>        (swap! app-state assoc-in [:releases] "res"))
> 
>       ;)}))
> 
>     om/IRenderState
> 
>     (render-state [_ _]
> 
>       (println data)
> 
>       (dom/div nil "release div"))
> 
>     ))
> 
> 
> 
> (om/root div-list app-state {:target (gdom/getElement "elem")})
> 
> 
> 
> First "init state" is printed, then the empty "app-state" atom and then the 
> "app-state" atom with the new data.
> 
> 
> 
> Thinking about it I guess it's correct that render-state is executed twice, 
> first on initialization and then after the change of the app-state.
> 
> However I guess it would make sense too if render-state is executed only 
> once, because it should be registered, after init-state was executed once.
> 
> 
> 
> So is this expected behavior I am seeing?
> 
> Btw. I use om 0.5.0.
> 
> 
> 
> Best Regards,
> 
> Sven
> 
> 
> 
> --
> 
> 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