Last active
January 16, 2018 15:00
-
-
Save eranharel/8aa533418bae84af20dcd6e310bb1212 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 listenablefuture-handler | |
[lf on-success-func on-fail-func] | |
(Futures/addCallback | |
lf | |
(reify FutureCallback | |
(onSuccess [_ res] | |
(on-success-func res)) | |
(onFailure [_ e] | |
(on-fail-func e)))) | |
lf) | |
(listenablefuture-handler (Futures/immediateFuture "666") | |
(fn [res] (println "Got results: " res)) | |
(fn [e] (println "Got error: " e))) | |
(listenablefuture-handler (Futures/immediateFailedFuture (new java.lang.RuntimeException)) | |
(fn [res] (println "Got results: " res)) | |
(fn [e] (println "Got error: " e))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment