title: RxJS - .subscribe() vs .publish().connect()
body: <p>This is mainly an RxJs best practice/approach question, since my POC code works but I'm brand new to RxJs.</p>
  
  <p>The question boils down to <code>.subscribe()</code> vs <code>.publish().connect()</code>, since they both appear to do the same thing.</p>
  
  <p>In my angular2 app, I have a button that calls a function to log the user out, which calls a function in my service that performs some server side actions and returns me a URL to redirect the user to.  In order to initiate the request I call <code>.subscribe()</code> to cause the observable to start producing values.  I was reading an article on "Cold vs Hot Observables" and it another approach would be to call <code>.publish().connect()</code> instead of <code>.subscribe()</code>. Is there any benefit to either approach. </p>
  
  <pre><code>&lt;a (click)="logout()"&gt;Logout&lt;/a&gt;
  </code></pre>
  
  <p>The logout function looks like this:</p>
  
  <p><strong>logout.component.ts</strong></p>
  
  <pre><code>logout() { this.authService.logout(); }
  </code></pre>
  
  <p>And the service (actual logout) looks like this:</p>
  
  <p><strong>auth.service.ts</strong>    </p>
  
  <pre><code>logout() : Observable&lt;boolean&gt;  {
          this.http.get(this.location.prepareExternalUrl('api/v1/authentication/logout'))
              .map(this.extractData)
              .catch(this.handleError)
              .do((x: string) =&gt; { window.location.href = x; })
              .subscribe();    // Option A - 
  
          return Observable.of(true);
  
      }
  </code></pre>
  
  <p><strong>auth.service.alternative.ts</strong>    </p>
  
  <pre><code>logout() : Observable&lt;boolean&gt;  {
          this.http.get(this.location.prepareExternalUrl('api/v1/authentication/logout'))
              .map(this.extractData)
              .catch(this.handleError)
              .do((x: string) =&gt; { window.location.href = x; })
              .publish()  // Option B - Make connectable observable
              .connect(); // Option B - Cause the connectable observable to subscribe and produce my value       
  
          return Observable.of(true);
      }
  </code></pre>