Class MaybeHelper

    • Constructor Detail

      • MaybeHelper

        public MaybeHelper()
    • Method Detail

      • nullObserver

        public static <T> MaybeObserver<T> nullObserver()
        Returns:
        a MaybeObserver that does nothing
      • toMaybe

        public static <T> Maybe<T> toMaybe​(java.util.function.Consumer<Handler<AsyncResult<T>>> handler)
        Returns a Maybe that, when subscribed, uses the provided handler to adapt a callback-based asynchronous method.

        For example:

         
         io.vertx.core.Vertx vertx = Vertx.vertx();
         Maybe<String> blockingMethodResult = MaybeHelper.toMaybe(handler -> vertx.<String>executeBlocking(fut -> fut.complete(invokeBlocking()), 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 Maybe is subscribed
      • toFuture

        public static <T> Future<T> toFuture​(Maybe<T> maybe)
        Adapts an RxJava2 Maybe<T> to a Vert.x Future.

        The maybe 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
      • toFuture

        public static <T,​U> Future<U> toFuture​(Maybe<T> maybe,
                                                     java.util.function.Function<T,​U> adapter)
        Like toFuture(Maybe) but with an adapter of the result.