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
- Host: GitHub
- URL: https://github.com/timboudreau/async-promises
- Owner: timboudreau
- Created: 2015-09-19T19:01:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T05:20:33.000Z (over 2 years ago)
- Last Synced: 2025-08-07T04:28:06.526Z (5 months ago)
- Topics: asynchronous, java, promises
- Language: Java
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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