Class CompletableHelper
java.lang.Object
io.vertx.rxjava3.CompletableHelper
- Author:
- Julien Viet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CompletableObserverstatic CompletabletoCompletable(Consumer<Handler<AsyncResult<Void>>> handler) Returns aCompletablethat, when subscribed, uses the providedhandlerto adapt a callback-based asynchronous method.toFuture(Completable maybe) static <T> CompletableObservertoObserver(Handler<AsyncResult<T>> handler) Adapts an Vert.xHandler<AsyncResult<T>>to an RxJava2SingleObserver.
-
Constructor Details
-
CompletableHelper
public CompletableHelper()
-
-
Method Details
-
nullObserver
- Returns:
- a
CompletableObserverthat does nothing
-
toCompletable
Returns aCompletablethat, when subscribed, uses the providedhandlerto 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 returnedCompletableis 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
-