Class ObservableConsumers


  • public final class ObservableConsumers
    extends java.lang.Object
    Utility methods for creating and using consumers Observables.
    Since:
    0.18.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> Disposable subscribeAutoDispose​(Observable<T> source, CompositeDisposable composite, Consumer<? super T> onNext)
      Wraps the given onXXX callbacks into a Disposable Observer, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the Observer is removed from the given composite.
      static <T> Disposable subscribeAutoDispose​(Observable<T> source, CompositeDisposable composite, Consumer<? super T> onNext, Consumer<? super java.lang.Throwable> onError)
      Wraps the given onXXX callbacks into a Disposable Observer, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the Observer is removed from the given composite.
      static <T> Disposable subscribeAutoDispose​(Observable<T> source, CompositeDisposable composite, Consumer<? super T> onNext, Consumer<? super java.lang.Throwable> onError, Action onComplete)
      Wraps the given onXXX callbacks into a Disposable Observer, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the Observer is removed from the given composite.
      • Methods inherited from class java.lang.Object

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

      • subscribeAutoDispose

        public static <T> Disposable subscribeAutoDispose​(Observable<T> source,
                                                          CompositeDisposable composite,
                                                          Consumer<? super T> onNext)
        Wraps the given onXXX callbacks into a Disposable Observer, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the Observer is removed from the given composite.

        The Observer will be removed after the callback for the terminal event has been invoked.

        Type Parameters:
        T - the value type
        Parameters:
        source - the source Observable to subscribe to.
        composite - the composite Disposable to add and remove the created Disposable Observer
        onNext - the callback for upstream items
        Returns:
        the Disposable that allows disposing the particular subscription.
      • subscribeAutoDispose

        public static <T> Disposable subscribeAutoDispose​(Observable<T> source,
                                                          CompositeDisposable composite,
                                                          Consumer<? super T> onNext,
                                                          Consumer<? super java.lang.Throwable> onError)
        Wraps the given onXXX callbacks into a Disposable Observer, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the Observer is removed from the given composite.

        The Observer will be removed after the callback for the terminal event has been invoked.

        Type Parameters:
        T - the value type
        Parameters:
        source - the source Observable to subscribe to.
        composite - the composite Disposable to add and remove the created Disposable Observer
        onNext - the callback for upstream items
        onError - the callback for an upstream error if any
        Returns:
        the Disposable that allows disposing the particular subscription.
      • subscribeAutoDispose

        public static <T> Disposable subscribeAutoDispose​(Observable<T> source,
                                                          CompositeDisposable composite,
                                                          Consumer<? super T> onNext,
                                                          Consumer<? super java.lang.Throwable> onError,
                                                          Action onComplete)
        Wraps the given onXXX callbacks into a Disposable Observer, adds it to the given CompositeDisposable and ensures, that if the upstream completes or this particlular Disposable is disposed, the Observer is removed from the given composite.

        The Observer will be removed after the callback for the terminal event has been invoked.

        Type Parameters:
        T - the value type
        Parameters:
        source - the source Observable to subscribe to.
        composite - the composite Disposable to add and remove the created Disposable Observer
        onNext - the callback for upstream items
        onError - the callback for an upstream error if any
        onComplete - the callback for the upstream completion if any
        Returns:
        the Disposable that allows disposing the particular subscription.