title: RxJava Maybe: Any neat way to handle Empty case?
body: <p>I am stuck at this problem, which should be fairly simple. I need subscriber to execute a code block when the <code>Maybe</code> has completed as an <code>Empty Maybe</code>. I found that </p>
  
  <ol>
  <li>we can pass default Maybe value or use switchIfEmpty but I feel both are hacky. </li>
  <li>Also there is a subscribe function which takes onComplete function (along with handlers for other two events), but onComplete does not take any argument which can be used to find if maybe was completed empty.</li>
  <li>Another way could be <code>Maybe.isEmpty.blockingGet()</code>, but it is dirty too.</li>
  </ol>
  
  <p>I have tried following (<em>Kotlin Syntax</em>):-</p>
  
  <pre><code>fun &lt;T&gt; Maybe&lt;T&gt;.subscribeWithEmptyHandler(onSuccess: (T) -&gt; Unit, onError: (Throwable) -&gt; Unit, onEmpty: () -&gt; Unit) {
      this.isEmpty.subscribe({ if (it) onEmpty() }, { onError(it) })
      this.subscribe({ onSuccess(it) }, { onError(it) })
  }
  </code></pre>
  
  <p>But as expected it is running subscription twice, tested here:-</p>
  
  <pre><code>Maybe.create&lt;Int&gt; {
      println("subscribing")
      //Remove line below to create Empty Maybe
      it.onSuccess(5)
      it.onComplete()
  }
      .subscribeWithEmptyHandler({println("success")},{println("error")},{println("empty")})
  </code></pre>
  
  <p>Could somebody please suggest neater way to solve this?</p>