public class Promise<T> extends Object
The future() method returns the Future associated with a promise, the future
can be used for getting notified of the promise completion and retrieve its value.
A promise extends Handler so it can be used as a callback.
original non RX-ified interface using Vert.x codegen.| Modifier and Type | Field and Description |
|---|---|
static io.vertx.lang.rx.TypeArg<Promise> |
__TYPE_ARG |
io.vertx.lang.rx.TypeArg<T> |
__typeArg_0 |
| Constructor and Description |
|---|
Promise(Object delegate,
io.vertx.lang.rx.TypeArg<T> typeArg_0) |
Promise(Promise delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
complete()
Calls
complete(null) |
void |
complete(T result)
Set the result.
|
boolean |
equals(Object o) |
void |
fail(String message)
Calls
fail(java.lang.Throwable) with the message. |
void |
fail(Throwable cause)
Set the failure.
|
Future<T> |
future() |
Promise |
getDelegate() |
int |
hashCode() |
static <T> Promise<T> |
newInstance(Promise arg) |
static <T> Promise<T> |
newInstance(Promise arg,
io.vertx.lang.rx.TypeArg<T> __typeArg_T) |
static <T> Promise<T> |
promise()
Create a promise that hasn't completed yet
|
String |
toString() |
boolean |
tryComplete()
Calls
tryComplete(null). |
boolean |
tryComplete(T result)
Like
complete(T) but returns false when the promise is already completed instead of throwing
an IllegalStateException, it returns true otherwise. |
boolean |
tryFail(String message)
Calls
fail(java.lang.Throwable) with the message. |
boolean |
tryFail(Throwable cause)
Like
fail(java.lang.Throwable) but returns false when the promise is already completed instead of throwing
an IllegalStateException, it returns true otherwise. |
public static final io.vertx.lang.rx.TypeArg<Promise> __TYPE_ARG
public final io.vertx.lang.rx.TypeArg<T> __typeArg_0
public Promise(Promise delegate)
public Promise getDelegate()
public static <T> Promise<T> promise()
public void complete(T result)
result - the resultpublic void complete()
complete(null)public void fail(Throwable cause)
cause - the failure causepublic void fail(String message)
fail(java.lang.Throwable) with the message.message - the failure messagepublic boolean tryComplete(T result)
complete(T) but returns false when the promise is already completed instead of throwing
an IllegalStateException, it returns true otherwise.result - the resultfalse when the future is already completedpublic boolean tryComplete()
tryComplete(null).false when the future is already completedpublic boolean tryFail(Throwable cause)
fail(java.lang.Throwable) but returns false when the promise is already completed instead of throwing
an IllegalStateException, it returns true otherwise.cause - the failure causefalse when the future is already completedpublic boolean tryFail(String message)
fail(java.lang.Throwable) with the message.message - the failure messagepublic Future<T> future()
Future associated with this promise, it can be used to be aware of the promise completionCopyright © 2021 Eclipse. All rights reserved.