Class AutoDisposable

  • All Implemented Interfaces:
    androidx.lifecycle.LifecycleObserver

    public class AutoDisposable
    extends java.lang.Object
    implements androidx.lifecycle.LifecycleObserver
    AutoDisposable class implements LifecycleObserver. It creates a CompositeDisposable object that will be automatically disposed when parent's lifecycle is destroyed.
    • Constructor Summary

      Constructors 
      Constructor Description
      AutoDisposable​(androidx.lifecycle.Lifecycle lifecycle)
      AutoDisposable constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(io.reactivex.disposables.Disposable disposable)
      Adds disposable to CompositeDisposable object
      • Methods inherited from class java.lang.Object

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

      • AutoDisposable

        public AutoDisposable​(@NonNull
                              androidx.lifecycle.Lifecycle lifecycle)
        AutoDisposable constructor. Creates new CompositeDisposable object and adds lifecycle observer.
        Parameters:
        lifecycle - - observes this lifecycle
    • Method Detail

      • add

        public void add​(io.reactivex.disposables.Disposable disposable)
                 throws java.lang.Throwable
        Adds disposable to CompositeDisposable object
        Parameters:
        disposable - - disposable that will be added
        Throws:
        java.lang.Throwable - - throws error if CompositeDisposable was not created yet