So tab and mult fixed my problem of broadcasting to more than one listener 
https://gist.github.com/dagda1/4dcbda12f99aa9434ace#file-tap-cljs-L6.

I still think this is a very complicated solution to what I am trying to 
achieve.

Any input appreciated.

On Sunday, November 2, 2014 3:17:29 PM UTC, Paul Cowan wrote:
> So I changed the text-box component to listen on a channel on IWIllMount
> 
> (will-mount [_]
>       (when-let [ch (om/get-shared owner [:channels :tab-changed])]
>         (go-loop []
>           (when-let [tab (<! ch)]
>             (do
>               (log/debug (str "we have received " (value tab)))
>               (om/set-state! owner value (value tab)))))))
> 
> And then I called put! from the parent component:
> 
> (will-mount [_]
>         (let [ch (get-active-tab)]
>           (go
>             (let [{:keys [tab]} (<! ch)]
>               (om/set-state! owner :title (:title tab))
>               (om/set-state! owner :url (:url tab))
>               (when-let [tab-changed (om/get-shared owner [:channels 
> :tab-changed])]
>                (put! tab-changed tab))))))
> 
> I am also now rendering 2 of these text-boxes:
> 
> (om/build ui/text-box data {:opts {:value :title}})
> (om/build ui/text-box data {:opts {:value :url}})
> 
> But the channel only receives a message on the first text-box component, do I 
> have to do anything for the channel to broadcast on multiple listeners?
> 
> I am a bit new to clojurescript, om etc.
> 
> On Sunday, November 2, 2014 2:15:32 PM UTC, Paul Cowan wrote:
> > I am confused about the role of the owner in om and how I can make the 
> > following component reusable.
> > 
> > I have this component that renders two textboxes:
> > 
> > https://gist.github.com/dagda1/b8a04c7516b62ea0eb46
> > 
> > On line 23 
> > https://gist.github.com/dagda1/b8a04c7516b62ea0eb46#file-dash-cljs-L23 I 
> > render an input of type text that gets updated when an async call completes 
> > in IWillMount and works as I expect.
> > 
> > I tried to abstract this into a component 
> > https://gist.github.com/dagda1/0eed04662a90db2e4a66.
> > 
> > One thing I have noticed which confuses me when calling om/build, is that 
> > you never pass the owner in, for example I am calling it like this:
> > 
> > (om/build ui/text-box data {:opts {:value :title}})
> > 
> > But the component func has a signature like this:
> > 
> > (defn text-box [state owner {:keys [value]}]
> > 
> > So the framework must be supplying the owner, the docs say that the owner 
> > is the backing Om component so would that be the text-box in this case?
> > 
> > Also this line will never resolve 
> > https://gist.github.com/dagda1/0eed04662a90db2e4a66#file-component-cljs-L13 
> > because I am guessing the owner is different.
> > 
> > So what is the best way of making this component reusable and updating when 
> > the property resolves from the calling component?  Would I need to set up a 
> > core.async channel and listen for events and update the node's value?  That 
> > seems a bit verbose for a simple case, is there a way of binding the two 
> > values together? Is there one-way binding in om that could accomplish this 
> > in a neater fashion?  I am coming to om from workign with ember a lot and 
> > I'm probably still thinking in terms of bindingings.
> > 
> > Can anyone suggest a way to keep this as reusable as possible or how to 
> > approach this seemingly common problem in om?

-- 
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