To see why you cannot pass changing information in opts:
The Om component function returns a reified instance of the protocols:
(defn my-component [app owner opts]
(reify
om/IRender
(render [_] (dom/div nil (:foo opts))))
The first time om/build is called with this and opts is passed in, a new
instance is created and returned. This instance sees the up to date opts,
which is closed over by the render function.
The second time om/build is called (on rerender), the component is already
mounted and the function is NOT called again, instead the existing instance
from the previous call is used. Therefore render sees the closed over value
of opts - ie the OLD value of opts.
The only way that the component would see the new opts is if the function
is called again, which only happens if the old component is unmounted and
then remounted (basically a new one is instanciated). But you wouldn't want
to do that just to update opts. This is what :state is for!
On Thu Dec 11 2014 at 10:21:29 PM Andrew <[email protected]> wrote:
> Ah, I see! Many thanks. I thought on a re-render the build-all would be
> sent again and opts evaluated again. I skimmed the documentation for info
> on this but didn't see anything. This is great to know. I guess that solves
> the state vs opts debate for me!
>
> --
> 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.