package com.ustwo.boilerplate.base;

import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

public abstract class BasePresenter<T extends BaseView> {
  private CompositeDisposable disposables;
  private T view;

  /**
   * On view attached.
   *
   * @param view View attached to the presenter
   */
  @CallSuper
  public void onViewAttached(@NonNull final T view) {
    if (this.view != null) {
      throw new IllegalStateException("View " + this.view + " is already attached. Cannot attach "
          + view);
    }
    this.view = view;
  }

  /**
   * On view detached.
   */
  @CallSuper
  public void onViewDetached() {
    if (view == null) {
      throw new IllegalStateException("View is already detached");
    }
    view = null;

    if (disposables != null) {
      disposables.dispose();
      disposables = null;
    }
  }

  /**
   * Dispose on view detach.
   *
   * @param disposable Disposable to be disposed of upon view detachment
   */
  @CallSuper
  protected void disposeOnViewDetach(@NonNull final Disposable disposable) {
    if (disposables == null) {
      disposables = new CompositeDisposable();
    }
    disposables.add(disposable);
  }

  public boolean isViewAttached() {
    return view != null;
  }
}

@@ -361,24 +361,68 @@
 ew attached.
+ To be called when your view is initialised.
 %0A   *%0A   * @
@@ -744,16 +744,113 @@
 etached.
+ Intended as a cleanup process that should be called when the view will no%0A   * longer be in use.
 %0A   */%0A 

Add clarification on expected usage of onViewAttached and onViewDetached