delight-promise
A basic promise implementation for Java.
Usage
Creating a promise:
Promise<Success> p1 = Promises.create(new Operation<Success>() {
@Override
public void apply(final ValueCallback<String> callback) {
// do work ...
callback.onSuccess(Success.INSTANCE);
}
});
Resolve promise:
Success succ = p1.get();
// will throw a RuntimeException if promise cannot be resolved.
Resolving multiple promises in parallel:
List<Success> res = Promises.parallel(p1, p2, ...);
Maven Dependency
<dependency>
<groupId>org.javadelight</groupId>
<artifactId>delight-promise</artifactId>
<version>[insert latest version]</version>
</dependency>
This artifact is available on Maven Central and BinTray.
Links
Part of Java Delight.