Package io.vertx.reactivex.core

## Class Promise<T>

- java.lang.Object
- - io.vertx.reactivex.core.Promise<T>

- All Implemented Interfaces:
    `io.vertx.lang.rx.RxDelegate`
  Direct Known Subclasses:
    `BaseBridgeEvent`, `ConnectionInitEvent`

      public class Promise<T>
      extends Object
      implements io.vertx.lang.rx.RxDelegate

  Represents the writable side of an action that may, or may not, have occurred yet.

  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.

  NOTE: This class has been automatically generated from the `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static io.vertx.lang.rx.TypeArg<Promise>` | `__TYPE_ARG` |
    `io.vertx.lang.rx.TypeArg<T>` | `__typeArg_0` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Promise​(Promise delegate)` |
    `Promise​(Object delegate, io.vertx.lang.rx.TypeArg<T> typeArg_0)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `complete()` | Calls `complete(null)`
    `void` | `complete​(T result)` | Set the result.
    `void` | `complete​(T result, Throwable failure)` |
    `boolean` | `equals​(Object o)` |
    `void` | `fail​(String message)` |
    `void` | `fail​(Throwable failure)` |
    `Future<T>` | `future()` |
    `Promise` | `getDelegate()` |
    `void` | `handle​(AsyncResult<T> asyncResult)` | Succeed or fail this promise with the `AsyncResult` event.
    `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
    `Single<T>` | `rxFuture()` |
    `void` | `succeed()` |
    `void` | `succeed​(T result)` |
    `String` | `toString()` |
    `boolean` | `tryComplete()` | Calls `tryComplete(null)`.
    `boolean` | `tryComplete​(T result)` | Like `complete(T, java.lang.Throwable)` 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.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<Promise> __TYPE_ARG

    - #### __typeArg_0

          public final io.vertx.lang.rx.TypeArg<T> __typeArg_0

  - ### Constructor Detail

    - #### Promise

          public Promise​(Promise delegate)

    - #### Promise

          public Promise​(Object delegate,
                         io.vertx.lang.rx.TypeArg<T> typeArg_0)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals​(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public Promise getDelegate()

      Specified by:
        `getDelegate` in interface `io.vertx.lang.rx.RxDelegate`

    - #### promise

          public static <T> Promise<T> promise()

      Create a promise that hasn't completed yet
      Returns:
        the promise

    - #### complete

          public void complete​(T result,
                               Throwable failure)

    - #### complete

          public void complete​(T result)

      Set the result. Any handler will be called, if there is one, and the promise will be marked as completed.

      Any handler set on the associated promise will be called.
      Parameters:
        `result` - the result

    - #### complete

          public void complete()

      Calls `complete(null)`

    - #### succeed

          public void succeed​(T result)

    - #### succeed

          public void succeed()

    - #### fail

          public void fail​(Throwable failure)

    - #### fail

          public void fail​(String message)

    - #### tryComplete

          public boolean tryComplete​(T result)

      Like `complete(T, java.lang.Throwable)` but returns `false` when the promise is already completed instead of throwing an `IllegalStateException`, it returns `true` otherwise.
      Parameters:
        `result` - the result
      Returns:
        `false` when the future is already completed

    - #### tryComplete

          public boolean tryComplete()

      Calls `tryComplete(null)`.
      Returns:
        `false` when the future is already completed

    - #### tryFail

          public 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.
      Parameters:
        `cause` - the failure cause
      Returns:
        `false` when the future is already completed

    - #### tryFail

          public boolean tryFail​(String message)

      Calls `fail(java.lang.Throwable)` with the `message`.
      Parameters:
        `message` - the failure message
      Returns:
        false when the future is already completed

    - #### future

          public Future<T> future()

      Returns:
        the `Future` associated with this promise, it can be used to be aware of the promise completion

    - #### rxFuture

          public Single<T> rxFuture()

      Returns:
        the `Future` associated with this promise, it can be used to be aware of the promise completion

    - #### handle

          public void handle​(AsyncResult<T> asyncResult)

      Succeed or fail this promise with the `AsyncResult` event.
      Parameters:
        `asyncResult` - the async result to handle

    - #### newInstance

          public static <T> Promise<T> newInstance​(Promise arg)

    - #### newInstance

          public static <T> Promise<T> newInstance​(Promise arg,
                                                   io.vertx.lang.rx.TypeArg<T> __typeArg_T)