promissum.core
A promise implementation for Clojure that uses jdk8 completable futures behind the scenes.
all
(all promises)
Given an array of promises, return a promise that is resolved when all the items in the array are resolved.
any
(any promises)
Given an array of promises, return a promise that is resolved when first one item in the array is resolved.
deliver
(deliver p)
(deliver p v)
Mark the promise as completed or rejected with optional value.
If value is not specified nil
will be used. If the value is instance of Throwable
the promise will be rejected.
future
macro
(future & body)
Takes a body of expressions and yields a promise object that will invoke the body in another thread. This is a drop in replacement for the clojure’s builtin future
function that return composable promises.
promise
(promise)
(promise v)
A promise constructor.
This is a polymorphic function and this is a list of possible arguments:
- throwable
- plain value
In case of the initial value is instance of Throwable
, rejected promise will be retrned. In case of a plain value (not throwable), a resolved promise will be returned.
reason
(reason p)
Get the rejection reason of this promise. Throws an error if the promise isn’t rejected.