Package io.vertx.rxjava3

## Class CompletableHelper

- java.lang.Object
- - io.vertx.rxjava3.CompletableHelper

-     public class CompletableHelper
      extends Object

  Author:
    Julien Viet

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CompletableHelper()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static CompletableObserver` | `nullObserver()` |
    `static Completable` | `toCompletable​(Consumer<Handler<AsyncResult<Void>>> handler)` | Returns a `Completable` that, when subscribed, uses the provided `handler` to adapt a callback-based asynchronous method.
    `static <T> Future<Void>` | `toFuture​(Completable maybe)` | Adapts an RxJava2 `Completable<T>` to a Vert.x ``.
    `static <T> CompletableObserver` | `toObserver​(Handler<AsyncResult<T>> handler)` | Adapts an Vert.x `Handler<AsyncResult<T>>` to an RxJava2 `SingleObserver`.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CompletableHelper

          public CompletableHelper()

  - ### Method Detail

    - #### nullObserver

          public static CompletableObserver nullObserver()

      Returns:
        a `CompletableObserver` that does nothing

    - #### toCompletable

          public static Completable toCompletable​(Consumer<Handler<AsyncResult<Void>>> handler)

      Returns a `Completable` that, when subscribed, uses the provided `handler` to adapt a callback-based asynchronous method.

      For example:

           io.vertx.core.Vertx vertx = Vertx.vertx();
           // ... later
           Completable undeploy = CompletableHelper.toCompletable(handler -> vertx.undeploy(deploymentId, handler));

      This is useful when using RxJava without the Vert.x Rxified API or your own asynchronous methods.

      Parameters:
        `handler` - the code executed when the returned `Completable` is subscribed

    - #### toObserver

          public static <T> CompletableObserver toObserver​(Handler<AsyncResult<T>> handler)

      Adapts an Vert.x `Handler<AsyncResult<T>>` to an RxJava2 `SingleObserver`.

      The returned observer can be subscribed to an `Single.subscribe(SingleObserver)`.

      Parameters:
        `handler` - the handler to adapt
      Returns:
        the observer

    - #### toFuture

          public static <T> Future<Void> toFuture​(Completable maybe)

      Adapts an RxJava2 `Completable<T>` to a Vert.x ``.

      The completable will be immediately subscribed and the returned future will be updated with the result of the single.

      Parameters:
        `maybe` - the single to adapt
      Returns:
        the future