title: How To Wait For an Optional Observable
body: <p>In my Angular application I have am making an optional HTTP call to check if a user exists.  Based on the result of this call, I either want to make another call or stop processing.  Without resorting to <code>.toPromise()</code>, how can I wait for a call that is made in an <code>if</code> block?</p>
  
  <pre><code>  onSomeEvent() {
      const contact: IContact = {
        ...this.userForm.value
      };
  
      let cancelProcessing = false;
  
      if (this.isNewUser()) {
        // *** This is optional
        this.userService.duplicateUserSearch(contact.email, contact.userName)
          .subscribe(result =&gt; {
            if (result.result !== '') {
              cancelProcessing = true;
            }
          });
      }
  
      // *** This statement is hit before the observable completes
      if (cancelProcessing) {
        return;
      }
  
      //  *** which means that this runs when it shouldn't
      this.userService.updateContact(contact)
        .subscribe(res =&gt; {
          this.activeModal.close(res);
        });
    }
  </code></pre>