Class RxJavaStreams


  • public final class RxJavaStreams
    extends Object
    Stream and Single implementations based on RxJava.
    • Method Detail

      • streamFromPublisher

        public static <V> Stream<V> streamFromPublisher​(org.reactivestreams.Publisher<V> publisher)
        Create a new Stream from the given Publisher.
        Type Parameters:
        V - Type of data emitted
        Parameters:
        publisher - The Publisher to convert
        Returns:
        A new Stream
      • streamFrom

        public static <V> Stream<V> streamFrom​(V value)
        Create a new Stream composed only of the given value.
        Type Parameters:
        V - Type of data emitted
        Parameters:
        value - The value emitted by this stream
        Returns:
        A new Stream
      • streamError

        public static <V> Stream<V> streamError​(Throwable error)
        Create a new Stream composed only of the given error.
        Type Parameters:
        V - Type of data emitted
        Parameters:
        error - The error emitted by this stream
        Returns:
        A new Stream
      • emptyStream

        public static <V> Stream<V> emptyStream()
        Create a new empty Stream.
        Type Parameters:
        V - Type of data emitted
        Returns:
        An empty Stream
      • singleFromPublisher

        public static <V> Single<V> singleFromPublisher​(org.reactivestreams.Publisher<V> publisher)
        Create a new Single from the given Publisher. If the Publisher produce more than one result, they'll be dropped and the inner Subscription cancelled.
        Type Parameters:
        V - Type of the datum emitted
        Parameters:
        publisher - The Publisher to convert
        Returns:
        A new Stream
      • singleFrom

        public static <V> Single<V> singleFrom​(V value)
        Create a new Single from the given value.
        Type Parameters:
        V - Type of the datum emitted
        Parameters:
        value - The value contained by this Single
        Returns:
        A new Single
      • singleError

        public static <V> Single<V> singleError​(Throwable error)
        Create a new Single from the given error.
        Type Parameters:
        V - Type of the datum emitted
        Parameters:
        error - The error emitted by this Single
        Returns:
        A new Single
      • newSingle

        public static <V> Single<V> newSingle​(Single.Emitter<V> emitter)
        Creates a bridge from callback world to Single.
        Type Parameters:
        V - Type of the datum emitted
        Parameters:
        emitter - Action to perform once this Single has been subscribed to.
        Returns:
        A new Single