-
-
Save jraines/4d2bc117e83fa5b0f9af to your computer and use it in GitHub Desktop.
core.async Promise.all equivalent attempt
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
(go (println (<! (a/into [] (a/merge (map original-image-dimensions (:items @app-state))))))) | |
(defn original-image-dimensions [item] | |
(let [sub clojure.string/replace | |
image_url (sub (:large_default_image_url item) #"large" "original") | |
img (js/Image.) | |
out (chan)] | |
(aset img "onload" (fn [] (this-as image | |
(put! out {:height (.-height image) | |
:width (.-width image)}) | |
(a/close! out)))) | |
(aset img "src" image_url) | |
out)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment