Promissum Api Documentation

Version: 0.3.3

promissum.core

A promise implementation for Clojure that uses jdk8 completable futures behind the scenes.

*executor*

dynamic

The main executor service for schedule promises.

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.

await

(await cs)(await cs ms)(await cs ms default)

branch

(branch p callback errback)

catch

(catch p callback)

Catch all promise chain helper.

chain

(chain p & funcs)

A variadic chain operation.

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.

done?

(done? p)

Returns true if promise p is done independently if successfully o exceptionally.

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.

pending?

(pending? p)

Returns true if promise p is stil in pending state.

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.

promise?

(promise? p)

Returns true if p is a promise instance.

reason

(reason p)

Get the rejection reason of this promise. Throws an error if the promise isn’t rejected.

rejected

(rejected e)

Takes a error e and return a rejected promise with that error.

rejected?

(rejected? p)

Returns true if promise p is completed exceptionally.

resolved

(resolved v)

Takes a value v and return a resolved promise with that value.

resolved?

(resolved? p)

Returns true if promise p is completed successfully.

then

(then p callback)

A chain helper for promises.