Class ObservableFromStream<T>

  • Type Parameters:
    T - the element type of the Stream
    All Implemented Interfaces:
    ObservableSource<T>

    public final class ObservableFromStream<T>
    extends Observable<T>
    Wraps a Stream and emits its values as an Observable sequence.
    Since:
    3.0.0
    • Field Detail

      • stream

        final java.util.stream.Stream<T> stream
    • Constructor Detail

      • ObservableFromStream

        public ObservableFromStream​(java.util.stream.Stream<T> stream)
    • Method Detail

      • subscribeActual

        protected void subscribeActual​(Observer<? super T> observer)
        Description copied from class: Observable
        Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observers.

        There is no need to call any of the plugin hooks on the current Observable instance or the Observer; all hooks and basic safeguards have been applied by Observable.subscribe(Observer) before this method gets called.

        Specified by:
        subscribeActual in class Observable<T>
        Parameters:
        observer - the incoming Observer, never null
      • subscribeStream

        public static <T> void subscribeStream​(Observer<? super T> observer,
                                               java.util.stream.Stream<T> stream)
        Subscribes to the Stream.
        Type Parameters:
        T - the element type of the flow
        Parameters:
        observer - the observer to drive
        stream - the sequence to consume
      • closeSafely

        static void closeSafely​(java.lang.AutoCloseable c)