-
-
Save jrasanen/5c257a64e814d111ecfc5c361fa451e8 to your computer and use it in GitHub Desktop.
Clojure implementation of all(promises).then(...) pattern from JavaScript
This file contains hidden or 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 getPromiseFn | |
[aPromise] | |
(fn [num] (Thread/sleep 10000) | |
(deliver aPromise (str num " done")))) | |
(def proms [(promise) (promise) (promise)]) | |
(def promFns (map getPromiseFn proms)) | |
(future (map deref proms)) | |
(future (map promFn (range 0 (count proms)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment