-
-
Save skrat/ef08d7e3c2914f9a9d2d2636c3c6ffcc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn api-call-with-cb [api-call cb] | |
(go (let [resp (<! (api-call))] | |
(if (= 200 (:status resp)) | |
[(:body resp) nil] | |
[nil resp])))) | |
(defn api-fetch | |
([api-call cb] (api-call-with-cb api-call cb)) | |
([api-call] (api-call-without-cb api-call))) | |
(defn make-callback [item] | |
(fn [aux] | |
(prn "Item in this fn" item) | |
(reset! rez aux))) | |
(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 | |
(make-callback item))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment