You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 30, 2021. It is now read-only.
iou.getPromise()
.then(newIThenCallable<Integer, Integer>() {
@OverridepublicIntegerapply(Integerinteger) throwsException {
returninteger * 42;
}
}, newIThenCallable<Object, Void>() {
@OverridepublicVoidapply(Objectreason) throwsException {
System.out.println(String.format("%s I can't do that.", reason));
returnnull;
}
});
iou.reject("I'm sorry, Dave."); // prints "I'm sorry, Dave. I can't do that."
Failing a promise
iou.getPromise()
.then(newIThenCallable<Integer, Integer>() {
@OverridepublicIntegerapply(Integerinput) throwsException {
thrownewException("I just don't care.");
}
})
.then(newIThenCallable<Integer, Void>() {
@OverridepublicVoidapply(Integerinput) throwsException {
System.out.println("What would you say it is you do here?");
returnnull;
}
}, newIThenCallable<Object, Void>() {
@OverridepublicVoidapply(Objectreason) throwsException {
System.out.println(
String.format("It's not that I'm lazy, it's that %s",
((Exception)reason).getMessage()));
returnnull;
}
});
iou.resolve(42); // prints "It's not that I'm lazy, it's that I just don't care."
About
IOU is a Promises/A+ compliant promise library for Java