Created
August 28, 2021 06:00
-
-
Save bsless/7ecd85183190e6ea30156e33ac63834b to your computer and use it in GitHub Desktop.
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 wrap-async | |
([af on-success on-failure] | |
(wrap-async af identity on-success on-failure)) | |
([af before on-success on-failure] | |
(fn -wrap [-next] | |
(fn -async [ctx respond raise] | |
(let [ctx (before ctx)] | |
(letfn [(-on-success [result] (-next (on-success ctx result)) respond raise) | |
(-on-failure [?error] (raise (on-failure ctx ?error)))] | |
(af ctx -on-success -on-failure))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment