An open API service indexing awesome lists of open source software.

https://github.com/timboudreau/async-promises

An library for chaining together asynchronous work as a set of promises
https://github.com/timboudreau/async-promises

asynchronous java promises

Last synced: about 2 months ago
JSON representation

An library for chaining together asynchronous work as a set of promises

Awesome Lists containing this project

README

          

Asynchronous Promises
=====================

This is a simple library for implementing the "promise" idiom in Java for the case that work is run asynchronously.

I.e.

AsyncPromise.create((Foo data, Trigger trigger) -> {
someLib.asyncCreateTheBar((Bar bar) -> { trigger(bar, null) });
});

The specific use case it was initially built for was putting a more intuitive API over MongoDB's async Java driver,
but this library has no dependencies and is useful for any similar use case.

The usually aspects of promises apply:

* The work will be run sequentially
* They can be chained together - AsyncPromise + AsyncPromise gets you an AyncPromise
* A PromiseContext allows data to be passed between promises
* Failure handlers callbacks can be attached to individual promises, and failures propagate backward to the nearest promise in the chain that has one, optionally continuing back if there are multiple handlers
* Promises of heterogenous types can be chained together