Package io.vertx.rxjava3

## Class SingleHelper

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

-     public class SingleHelper
      extends Object

  Author:
    Julien Viet

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static SingleObserver<?>` | `NULL_OBSERVER` |

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static <T> SingleObserver<T>` | `nullObserver()` |
    `static <T> Future<T>` | `toFuture​(Single<T> single)` | Adapts an RxJava2 `Single<T>` to a Vert.x `Future`.
    `static <T,​U> Future<U>` | `toFuture​(Single<T> single, java.util.function.Function<T,​U> adapter)` | Like `toFuture(Single)` but with an `adapter` of the result.
    `static <T> SingleObserver<T>` | `toObserver​(Handler<AsyncResult<T>> handler)` | Adapts an Vert.x `Handler<AsyncResult<T>>` to an RxJava2 `SingleObserver`.
    `static <T> Single<T>` | `toSingle​(java.util.function.Consumer<Handler<AsyncResult<T>>> handler)` | Returns a `Single` that, when subscribed, uses the provided `handler` to adapt a callback-based asynchronous method.
    `static <T> SingleTransformer<Buffer,​T>` | `unmarshaller​(TypeReference<T> mappedTypeRef)` |
    `static <T> SingleTransformer<Buffer,​T>` | `unmarshaller​(TypeReference<T> mappedTypeRef, ObjectCodec mapper)` |
    `static <T> SingleTransformer<Buffer,​T>` | `unmarshaller​(Class<T> mappedType)` |
    `static <T> SingleTransformer<Buffer,​T>` | `unmarshaller​(Class<T> mappedType, ObjectCodec mapper)` |

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

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

- - ### Field Detail

    - #### NULL_OBSERVER

          public static final SingleObserver<?> NULL_OBSERVER

  - ### Constructor Detail

    - #### SingleHelper

          public SingleHelper()

  - ### Method Detail

    - #### nullObserver

          public static <T> SingleObserver<T> nullObserver()

      Returns:
        a `SingleObserver` that does nothing

    - #### toSingle

          public static <T> Single<T> toSingle​(java.util.function.Consumer<Handler<AsyncResult<T>>> handler)

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

      For example:

           io.vertx.core.Vertx vertx = Vertx.vertx();
           Single<String> deploymentId = SingleHelper.toSingle(handler -> vertx.deployVerticle("org.acme.MyVerticle", handler));

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

      The asynchronous method result must not be `null`, as an RxJava 2 `Single` does not allow `null` values.

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

    - #### toObserver

          public static <T> SingleObserver<T> 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<T> toFuture​(Single<T> single)

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

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

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

    - #### toFuture

          public static <T,​U> Future<U> toFuture​(Single<T> single,
                                                       java.util.function.Function<T,​U> adapter)

      Like `toFuture(Single)` but with an `adapter` of the result.

    - #### unmarshaller

          public static <T> SingleTransformer<Buffer,​T> unmarshaller​(Class<T> mappedType)

    - #### unmarshaller

          public static <T> SingleTransformer<Buffer,​T> unmarshaller​(TypeReference<T> mappedTypeRef)

    - #### unmarshaller

          public static <T> SingleTransformer<Buffer,​T> unmarshaller​(Class<T> mappedType,
                                                                           ObjectCodec mapper)

    - #### unmarshaller

          public static <T> SingleTransformer<Buffer,​T> unmarshaller​(TypeReference<T> mappedTypeRef,
                                                                           ObjectCodec mapper)