Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created July 5, 2013 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/5936471 to your computer and use it in GitHub Desktop.
Save swannodette/5936471 to your computer and use it in GitHub Desktop.
(defn event-chan
([type] (event-chan js/window type))
([el type] (event-chan (chan (sliding-buffer 1)) el type))
([c el type]
(.addEventListener el type #(put! c %))
c))
(defn jsonp-chan
([uri] (jsonp-chan (chan) uri))
([c uri]
(let [jsonp (goog.net.Jsonp. (goog.Uri. uri))]
(.send jsonp nil #(put! c %))
c)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment