title: RxJS Looking for something like "delayUntil"
body: <p>I have two functions, one returns <code>observableA</code> and one <code>observableB</code>. I want the getter as well as the subscription of <code>observableB</code> to delay until <code>observableA</code> is complete (but it can also be the case then when I’m subscribing to <code>observableB</code>, <code>observableA</code> is already completed).</p>
  
  <p>I’ve already tried to use <code>pipe</code> and <code>skipUntil</code> but unfortunately this only prevents the execution and doesn’t delays it if <code>observableA</code> is not completed yet.</p>
  
  <pre class="lang-js prettyprint-override"><code>functionA() {
    this.observableA$ = getObservableA()
    this.observableA$.subscribe(_ =&gt; {
      // A: This line should execute *before* line B
    })
  }
  
  functionB() {
    this.observableB$ = getObservableB()  // This getter should execute *after* line A
    this.observableB$.subscribe(_ =&gt; {
      // B: This line should execute *after* line A
    })
  }
  
  // Two functions are called independently
  functionA()
  functionB()
  </code></pre>
  
  <p>Would be great to find a very RxJS-ish way :)</p>
  
  <hr>
  
  <p><strong>Update 1: The problem with <code>concat</code>:</strong>
  As noted both functions are called independently which would result in a double-execution of <code>observableA$</code> when using <code>concat</code> like suggested. Also the subscription in <code>functionB</code> would be executed twice what I don't want.</p>
  
  <pre class="lang-js prettyprint-override"><code>functionA() {
    this.observableA$ = getObservableA()
    this.observableA$.subscribe(_ =&gt; {
      // A: This line should execute *before* line B
    })
  }
  
  functionB() {
    Observable.concat(
      this.observableA$,  // I get executed once again :(
      Observable.defer(() =&gt; getObservableB())  // To prevent earlier execution
    ).subscribe(() =&gt; {
      // B: This line should execute *after* line A
      console.log("I'm logged twice, once for each observable :(")
    })
  }
  
  // Two functions are called independently
  functionA()
  functionB()
  </code></pre>
  
  <hr>
  
  <p><strong>Update 2: @Wilhelm Olejnik solved it by using an additional <code>BehaviorSubject</code></strong></p>