public class SingleHelper extends Object
Constructor and Description |
---|
SingleHelper() |
Modifier and Type | Method and Description |
---|---|
static <T> io.reactivex.SingleObserver<T> |
toObserver(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
Adapts an Vert.x
Handler<AsyncResult<T>> to an RxJava2 SingleObserver . |
static <T> io.reactivex.Single<T> |
toSingle(Consumer<io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>> handler)
Returns a
Single that, when subscribed, uses the provided handler to adapt a callback-based asynchronous method. |
static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> |
unmarshaller(Class<T> mappedType) |
static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> |
unmarshaller(Class<T> mappedType,
com.fasterxml.jackson.databind.ObjectMapper mapper) |
static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> |
unmarshaller(com.fasterxml.jackson.core.type.TypeReference<T> mappedTypeRef) |
static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> |
unmarshaller(com.fasterxml.jackson.core.type.TypeReference<T> mappedTypeRef,
com.fasterxml.jackson.databind.ObjectMapper mapper) |
public static <T> io.reactivex.Single<T> toSingle(Consumer<io.vertx.core.Handler<io.vertx.core.AsyncResult<T>>> handler)
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.
handler
- the code executed when the returned Single
is subscribedpublic static <T> io.reactivex.SingleObserver<T> toObserver(io.vertx.core.Handler<io.vertx.core.AsyncResult<T>> handler)
Handler<AsyncResult<T>>
to an RxJava2 SingleObserver
.
The returned observer can be subscribed to an Single.subscribe(SingleObserver)
.
handler
- the handler to adaptpublic static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> unmarshaller(Class<T> mappedType)
public static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> unmarshaller(com.fasterxml.jackson.core.type.TypeReference<T> mappedTypeRef)
public static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> unmarshaller(Class<T> mappedType, com.fasterxml.jackson.databind.ObjectMapper mapper)
public static <T> io.reactivex.SingleTransformer<io.vertx.core.buffer.Buffer,T> unmarshaller(com.fasterxml.jackson.core.type.TypeReference<T> mappedTypeRef, com.fasterxml.jackson.databind.ObjectMapper mapper)
Copyright © 2020 Eclipse. All rights reserved.