Class SingleHelper
java.lang.Object
io.vertx.rxjava3.SingleHelper
- Author:
- Julien Viet
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SingleObserver<T> static <T> Future<T> Adapts an RxJava2Single<T>to a Vert.xFuture<T>.static <T,U> Future <U> LiketoFuture(Single)but with anadapterof the result.static <T> SingleObserver<T> toObserver(Handler<AsyncResult<T>> handler) Adapts an Vert.xHandler<AsyncResult<T>>to an RxJava2SingleObserver.static <T> Single<T> toSingle(Consumer<Handler<AsyncResult<T>>> handler) Returns aSinglethat, when subscribed, uses the providedhandlerto 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)
-
Field Details
-
NULL_OBSERVER
-
-
Constructor Details
-
SingleHelper
public SingleHelper()
-
-
Method Details
-
nullObserver
- Returns:
- a
SingleObserverthat does nothing
-
toSingle
Returns aSinglethat, when subscribed, uses the providedhandlerto 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 2Singledoes not allownullvalues.- Parameters:
handler- the code executed when the returnedSingleis subscribed
-
toObserver
Adapts an Vert.xHandler<AsyncResult<T>>to an RxJava2SingleObserver.The returned observer can be subscribed to an
Single.subscribe(SingleObserver).- Parameters:
handler- the handler to adapt- Returns:
- the observer
-
toFuture
-
toFuture
LiketoFuture(Single)but with anadapterof the result. -
unmarshaller
-
unmarshaller
-
unmarshaller
-
unmarshaller
public static <T> SingleTransformer<Buffer,T> unmarshaller(TypeReference<T> mappedTypeRef, ObjectCodec mapper)
-