I would recommend using clojurescript , which has awesome core-async , which makes life easier when working with asynchronous calls.
In your case, you should write something like this:
(go (when-let [res1 (<! (asyncFunc1))] (<! (asyncFunc2 res1))) (<! (asyncFunc3)))
Pay attention to the go macro, which will make the body work asynchronously, and the <! , which will be blocked until async functions are returned.
First, the code will block at the first asynchronous function. Then, if the result of this is true, it will also run the second asynchronous function in the block. Finally, it will run the third async function and block it.
Asher source share