plumatic / dommy

A tiny ClojureScript DOM manipulation and event library
759 stars 74 forks source link

Suggestion: listen-chan! #42

Closed JulianBirch closed 10 years ago

JulianBirch commented 11 years ago

listen-chan! could either set up a listen that writes to a provided channel, or create the channel itself. The latter is more convenient in the usual case, the former is more desirable in the general case.

cpetzold commented 10 years ago

By channel, do you mean core.async? My only concern is that you then force a dependency on core.async. I think this is simple enough and can be application-specific:

(defn listen-chan! [node event-type]
  (let [c (chan)]
    (dommy/listen! node event-type #(put! c %))
    c))
JulianBirch commented 10 years ago

I do, but my understanding is that any dependency on core.async would be stripped out by advanced optimizations anyway.