Hi Lucas, that is actually what I am doing in reality. I tend to have very 
generic components which do everything via channels and are entirely read only.

To save boilerplate I then have equivalent "bound-" component which knows how 
to bind the component into the app-state. The "bound-" component will create 
and listen to those channels and update the app-state accordingly.

I find this works quite nicely, so I have a 'tree' component for example, which 
allows expansion and collapse but has no idea how to actually do that. onClicks 
all go into a channel.

I have about 8 instances of that tree in my app all with the same relevant 
app-state structure so I have a bound-tree which takes (-> cursor :page-x 
:what-ever-needs-the-tree). In the example I collapsed them together I expect 
for simplicity.

On a completely related note; I have just wasted 3 hours of my life tracking 
down why on earth I was seeing the following:
 - component renders
 - the first change in app state was persisted
 - the second change would overwrite the first change

Huh? Where do you even start looking for that.

Turns out I was doing an (om/set-state! cursor (conj cursor id)) in a callback 
(I realise this is equivalent to (om/transact! cursor (conj id)) but there is a 
reason I am doing it this way). 

Of course, the answer is obvious when you spot it: (om/set-state! cursor (conj 
@cursor id)). 

Numpty points 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.

Reply via email to