Skip to content

Instantly share code, notes, and snippets.

@neotyk
Created May 10, 2012 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neotyk/2652052 to your computer and use it in GitHub Desktop.
Save neotyk/2652052 to your computer and use it in GitHub Desktop.
http.async.client callback counting body parts
;; counting body parts
(http-r/execute-request
c (http-r/prepare-request :get "http://localhost:8080/json")
:part (fn [resp part]
(let [counter (if (realized? (:body resp)) (:body resp) (atom 0))]
(swap! counter inc)
(println :p part)
[counter :continue]))
:completed (fn [resp]
(println :d @@(:body resp);atom within a promise
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment