title: When to unsubscribe a subscription
body: <p>I have a question regarding how to unsubscribe an observable. I have two codes and I'm not really sure about which one is better.</p>
  
  <p>Example 1 -> Unsubscribe the subscriber once the stream has finished:</p>
  
  <pre><code>Subscriber&lt;String&gt; subscriber = new Subscriber&lt;String&gt;() {
          @Override
          public void onCompleted() {
              progressdialog.dissmiss();
              unsubscribe();
          }
  
          @Override
          public void onError(Throwable e) {
              progressdialog.dissmiss();
          }
  
          @Override
          public void onNext(String s) {
              // do something with data
          }
      }
  </code></pre>
  
  <p>Example 2 -> Unsubscribe the subscription once the activity is destroyed:</p>
  
  <pre><code>private void test(){
      Subscriber&lt;String&gt; subscriber = new Subscriber&lt;String&gt;() {
          @Override
          public void onCompleted() {
              progressdialog.dissmiss();
          }
  
          @Override
          public void onError(Throwable e) {
              progressdialog.dissmiss();
          }
  
          @Override
          public void onNext(String s) {
              // do something with data
          }
      };
  
      subscription = BackendRequest.login(loginRequest)
              .subscribeOn(Schedulers.newThread())
              .observeOn(AndroidSchedulers.mainThread())
              .subscribe(subscriber);
  
      compositeSubscription.add(subscription);
  }
  
  @Override
  protected void onDestroy() {
      super.onDestroy();
      this.subscription.unsubscribe();
  }
  </code></pre>
  
  <p>I have to mention that my observables only will emit once, the activity should not wait for more calls from the Observable.</p>
  
  <p>Which one is better?</p>
  
  <p>Thanks in advance</p>