T
- the type of promised valuepublic interface Promise<T> extends SuccessPromise<T>
A promise allows what is to be done with the value to be specified without having the value available. They are a common alternative to callbacks in asynchronous programming.
Promise instances cannot be reused. Furthermore, only one method can be called on any promise instance.
Methods returning a promise (or success promise) return a new promise instance, which can also only be used once. Once any method has been called on a given promise object, calling any other method will throw an exception.
To test code that uses promises, see the ratpack.test.exec.ExecHarness
class.
Modifier and Type | Method and Description |
---|---|
default void |
asResult(Action<? super Result<T>> resultHandler) |
SuccessPromise<T> |
onError(Action<? super Throwable> errorHandler)
Specifies the action to take if the an error occurs trying to produce the promised value.
|
void |
then(Action<? super T> then)
Specifies what should be done with the promised object when it becomes available.
|
SuccessPromise<T> onError(Action<? super Throwable> errorHandler)
errorHandler
- the action to take if an error occursvoid then(Action<? super T> then)
then
in interface SuccessPromise<T>
then
- the receiver of the promised value