title: Observable wait for a method to complete
body: <p>I want to run method A and B parallelly and once they both are done, I want to run method C.</p>
  
  <p>How can I achieve this in javascript using Observable? </p>
  
  <pre><code>main() {
  
      this.methodA();
      if(some_condition) this.methodB();
      this.methodC();
  
  }
  
  methodA() {
      setTimeout( () =&gt; { console.log("doing some work A"); }, 500);
  }
  
  methodB() {
      setTimeout( () =&gt; { console.log("doing some work B"); }, 250);
  }
  
  methodC() {
      console.log("should be the last...");
  }    
  </code></pre>
  
  <p>expected output (if some_condition is false):</p>
  
  <p>doing some work A</p>
  
  <p>should be the last...</p>
  
  <p>expected output (if some_condition is true):</p>
  
  <p>doing some work A</p>
  
  <p>doing some work B</p>
  
  <p>should be the last...</p>
  
  <p>expected output (if some_condition is true):</p>
  
  <p>doing some work B</p>
  
  <p>doing some work A</p>
  
  <p>should be the last...</p>