Skip to content

Instantly share code, notes, and snippets.

Created June 8, 2017 09:06
Show Gist options
  • Save anonymous/8d9fe204c144a8b11155e0cb33d97d1e to your computer and use it in GitHub Desktop.
Save anonymous/8d9fe204c144a8b11155e0cb33d97d1e to your computer and use it in GitHub Desktop.
(defn api-call-with-cb [api-call cb]
(go (let [resp (<! (api-call))]
(if (= 200 (:status resp))
(cb (:body resp))
(treat-error resp)))))
(defn api-fetch
([api-call cb] (api-call-with-cb api-call cb))
([api-call] (api-call-without-cb api-call)))
(go
(prn "Items " @items) ;; prints items collection with data in it
(doseq [item @items]
(prn "this is t " item) ;; prints a map (one item of @items collection)
(<! (api-fetch #(get-stuff (:_id item)) ;; chrome dev tools show the request made with :_id param read correctly
(fn [aux]
;; this prints 30, when built with: lein do clean, uberjar
;; print a map item of @item in develpment mode
;; what, how and why is this happening??
(prn "Item in this fn" item)
(reset! rez aux))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment