Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by

Based on https://dev.clojure.org/display/design/Promises

Discussion on Slack:

Enhance future/promise to be able to call a function on completion/failure (I'd use promises a lot more if I had this functionality but you can sort of hack around it in ugly ways with futures and/or additional functions/macros).

2 Answers

+1 vote
Reference: https://clojure.atlassian.net/browse/CLJ-2487 (reported by seancorfield)
0 votes

The design document moved to https://archive.clojure.org/design-wiki/display/design/Promises.html and it predates java.util.concurrent.CompletableFuture which provides all of those features (and more).

After some discussion with Ghadi, I decided to just write a few macros to provide syntactic sugar for the basic operations I needed. They can be found in https://github.com/worldsingles/commons

(-> (completable (do-some-stuff))
    (then some-function)
    (exceptionally an-exception-handler)