In re-frame event dispatching is handled by (dispatch [:discriminator detail]). 
A corresponding (register-handler :discriminator (fn [db [_ detail]]) then 
reacts to that dispatched event.

My question is how are people managing this with re-usable components? For 
example, I have a tree and when selecting a node in that tree something should 
happen. But this is where it gets all polymorphic as _what_ happens depends on 
the client who instantiated the tree. I can see the following ways forward:

 - tree is configured with a 'context' key which is combined with the 
discriminator so rather than the tree emitting :node-selected it emits 
:consumer-a-node-selected. Consumer a can then handle consumer-a-node-selected 
and consumer b can handle (go on, guess) consumer-b-node-selected
 - a variation on the above involving writing your own dispatching logic...
 - tree doesn't use dispatch as the event bus, rather it takes in an instance 
of a Protocol: 
  IRespondToTree
  (on-node-select [this node])
 - tree is parameterised with a map of fns {:node-selected-fn ...} etc.

How would you all handle it? (I am leaning towards the first one).

-- 
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 clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to