Class Subjects


  • public final class Subjects
    extends java.lang.Object
    Utility methods to work with RxJava 2 Subjects.
    Since:
    0.18.2
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> @NonNull Subject<T> refCount​(Subject<T> subject)
      Wraps a Subject and makes sure if all observers dispose their disposables, the upstream's Disposable gets disposed as well.
      • Methods inherited from class java.lang.Object

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

      • refCount

        @NonNull
        @CheckReturnValue
        public static <T> @NonNull Subject<T> refCount​(Subject<T> subject)
        Wraps a Subject and makes sure if all observers dispose their disposables, the upstream's Disposable gets disposed as well.

        This operator is similar to ConnectableObservable.refCount() except the first Observer doesn't trigger any sort of connection; that happens when the resulting Subject is subscribed to an Observable manually.

        Type Parameters:
        T - the input and output value type
        Parameters:
        subject - the subject to wrap, not null
        Returns:
        the wrapped and reference-counted Subject
        Since:
        2.1.8 - experimental