title: TypeScript Global variables not changed in Observable subscribe method
body: <p>I am trying to use rxJS to handle responses from an http request in angular2</p>
  
  <p>this is the code:</p>
  
  <pre><code>isUserConfirmed(): boolean {
      let result: boolean = false;
      this.authService.isUserConfirmed().subscribe(
        retrievedData =&gt; {
          //if no errors from the server
          if (retrievedData.success) {
            //if the confirmed flag is true
            if (retrievedData.payload){
              result = true;
              console.log("i"+result);
            } else {
              result = false;
  
            }
          } else {
            this.showError(retrievedData.message);
          }
        },
        error =&gt; {
          this.showError(error);
        });
        console.log("o"+result);
        return result;
    },
  
  showError(error) {
    //...
  }
  </code></pre>
  
  <p><strong>EDIT</strong>  </p>
  
  <p>When I run this, I get this output:  </p>
  
  <p><code>ofalse</code><br>
  <code>itrue</code>  </p>
  
  <p>This means that the result value is set to true inside suscribe method, but  that does not change returned result value.<br>
  How can I manage to return the value set from inside the subscribe block?</p>