Class RxJavaInterop


  • public class RxJavaInterop
    extends java.lang.Object
    Static factory class that provides methods to obtain commonly used instances for interoperation between RxJava and standard JRE.
    Since:
    10.0
    Author:
    wburns
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.function.Function<java.util.concurrent.CompletionStage<?>,​io.reactivex.Completable> completionStageToCompletable()  
      static <E> java.util.function.Function<java.util.concurrent.CompletionStage<E>,​io.reactivex.Flowable<E>> completionStageToPublisher()
      Provides an interop function that can be used to convert a CompletionStage into a Flowable.
      static <K,​V>
      io.reactivex.functions.Function<java.util.Map.Entry<K,​V>,​K>
      entryToKeyFunction()
      Provides a Function that can be used to convert from an instance of Map.Entry to the key of the entry.
      static <E> io.reactivex.functions.Function<io.reactivex.Flowable<E>,​java.util.concurrent.CompletionStage<java.lang.Void>> flowableToCompletionStage()
      Provides an interop function that can be used to convert a Flowable into a CompletionStage.
      static <E> io.reactivex.Flowable<E> fromStream​(java.util.stream.Stream<E> stream)
      Transforms a Stream to a Flowable.
      static <E> io.reactivex.functions.Function<io.reactivex.Maybe<E>,​java.util.concurrent.CompletionStage<E>> maybeToCompletionStage()
      Provides an interop function that can be used to convert a Maybe into a CompletionStage.
      static <E> io.reactivex.functions.Function<io.reactivex.Single<E>,​java.util.concurrent.CompletionStage<E>> singleToCompletionStage()
      Provides an interop function that can be used to convert a Single into a CompletionStage.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • singleToCompletionStage

        public static <E> io.reactivex.functions.Function<io.reactivex.Single<E>,​java.util.concurrent.CompletionStage<E>> singleToCompletionStage()
        Provides an interop function that can be used to convert a Single into a CompletionStage. Note that this function is not from the standard java.util.function package, but rather Function to interop better with the Single.to(Function) method.
        Type Parameters:
        E - underlying type
        Returns:
        rxjava function to convert Single to CompletionStage
      • maybeToCompletionStage

        public static <E> io.reactivex.functions.Function<io.reactivex.Maybe<E>,​java.util.concurrent.CompletionStage<E>> maybeToCompletionStage()
        Provides an interop function that can be used to convert a Maybe into a CompletionStage. Note that this function is not from the standard java.util.function package, but rather Function to interop better with the Maybe.to(Function) method.
        Type Parameters:
        E - underlying type
        Returns:
        rxjava function to convert Maybe to CompletionStage
      • flowableToCompletionStage

        public static <E> io.reactivex.functions.Function<io.reactivex.Flowable<E>,​java.util.concurrent.CompletionStage<java.lang.Void>> flowableToCompletionStage()
        Provides an interop function that can be used to convert a Flowable into a CompletionStage. Note that this function is not from the standard java.util.function package, but rather Function to interop better with the Maybe.to(Function) method. Any published values are ignored and the returned CompletionStage is completed when the Flowable completes or completed exceptionally if the Flowable has an error.
        Returns:
        rxjava function to convert Flowable to CompletionStage
      • completionStageToPublisher

        public static <E> java.util.function.Function<java.util.concurrent.CompletionStage<E>,​io.reactivex.Flowable<E>> completionStageToPublisher()
        Provides an interop function that can be used to convert a CompletionStage into a Flowable. Note that this function is from the standard java.util.function package since we don't want the method to throw an exception

        Remember that the CompletionStage when completing normally MUST have a non null value!

        Type Parameters:
        E - underlying type
        Returns:
        java.util function to convert CompletionStage to Flowable
      • completionStageToCompletable

        public static java.util.function.Function<java.util.concurrent.CompletionStage<?>,​io.reactivex.Completable> completionStageToCompletable()
      • fromStream

        public static <E> io.reactivex.Flowable<E> fromStream​(java.util.stream.Stream<E> stream)
        Transforms a Stream to a Flowable. Note that the resulting Flowable can only be subscribed to once as a Stream only allows a single terminal operation performed upon it. When the Flowable is completed, either exceptionally or normally, the Stream is also closed
        Type Parameters:
        E - inner type
        Parameters:
        stream - the stream to transform to a Flowable
        Returns:
        Flowable that can only be subscribed to once
      • entryToKeyFunction

        public static <K,​V> io.reactivex.functions.Function<java.util.Map.Entry<K,​V>,​K> entryToKeyFunction()
        Provides a Function that can be used to convert from an instance of Map.Entry to the key of the entry. This is useful for the instance passed to a method like Flowable.map(Function).
        Type Parameters:
        K - key type
        V - value type
        Returns:
        rxjava function to convert from a Map.Entry to its key.