Created
September 29, 2016 12:33
-
-
Save savelichalex/a61d792987eb231e7cce9a8b185ad62b 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
(defmacro then-> | |
[promise & forms] | |
(loop [promise promise, | |
forms forms] | |
(if forms | |
(let [form (first forms) | |
catch? (= form :catch) | |
threaded (if (true? catch?) | |
(with-meta `(.catch ~promise ~(first (next forms))) (meta (first (next forms)))) | |
(with-meta `(.then ~promise ~form) (meta form)))] | |
(recur threaded (if (true? catch?) | |
(next (next forms)) | |
(next forms)))) | |
promise))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment