title: RxJava Relay vs Subjects
body: <p>I'm trying to understand the purpose of this library by Jake Warthon: 
  <a href="https://github.com/JakeWharton/RxRelay" rel="noreferrer">https://github.com/JakeWharton/RxRelay</a></p>
  
  <blockquote>
    <p>Basically: A Subject except without the ability to call onComplete or
    onError. Subjects are stateful in a damaging way: when they receive an
    onComplete or onError they no longer become usable for moving data.</p>
  </blockquote>
  
  <p>I get idea, it's a valid use case, but the above seems easy to achieve just using the existing subjects. </p>
  
  <p><strong>1.</strong> Don't forward <code>errors</code>/<code>completions</code> events to the subject:</p>
  
  <pre><code>`observable.subscribe({ subject.onNext(it) }, { log error / throw exception },{ ... })`
  </code></pre>
  
  <p><strong>2.</strong> Don't expose the subject, make your method signature return an observable instead.</p>
  
  <p><code>fun(): Observable&lt;&gt; { return subject }</code></p>
  
  <p>I'm obviously missing something here and I'm very curios on what it is!</p>
  
  <pre><code>class MyPublishRelay&lt;I&gt; : Consumer&lt;I&gt; {
  
      private val subject: Subject&lt;I&gt; = PublishSubject.create&lt;I&gt;()
  
      override fun accept(intent: I) = subject.onNext(intent)
  
      fun subscribe(): Disposable = subject.subscribe()
      fun subscribe(c: Consumer&lt;in I&gt;): Disposable = subject.subscribe(c)
      //.. OTHER SUBSCRIBE OVERLOADS
  }
  </code></pre>