nchubrich wrote: > I'm curious what the best idiomatic way of handling events is (e.g. > receiving a series of messages and dispatching functions on the basis > of the messages). One could use the 'experimental' add-watch(er) > functions. But it might also be nice to do something stream-oriented, > e.g. a doseq on a stream of events. But the trouble is this dies as > soon as the events stop arriving. Can event seqs be 'kept alive' > somehow (preferably without blocking)?
I may be misunderstanding what you mean by events but what about just using an agent and a multi-method? (defmulti handle-event (fn [state event] (:type event))) (defmethod handle-event :party [state event] (assoc state :status :dancing)) (defmethod handle-event :explosion [state event] (assoc state :status :cowering)) (def my-agent (agent {})) (send my-agent handle-event {:type :party, :location :your-house}) @my-agent => {:status :dancing} -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en