title: RxJS pipe chaining with IF statement in the middle
body: <p>I am getting a value, and based on the return, if data actually returned the first time I just send it through and carry on, else if nothing returns I get default values and carry on with the data. </p>
  
  <p>My problem is returning the default data after the IF statement. I can not get it to return the data, instead of the observable/subscription</p>
  
  <p>It looks something like this:</p>
  
  <pre><code>getValuesFunction() {
      const getFirstValues$ = this.ApiCall.getFirstValues();
      this.subscription = getFirstValues$.pipe(
          map(data =&gt; {
             if (data.length === 0) {
                // this line is the one I have a problem with
                return this.processedStockApi.getDefaultValues().subscribe();
             } else {
                // this line returns fine
                return data;
             }
          }),
          switchMap(data =&gt; this.apiCall.doSomethingWithData(data))
      ).subscribe();
  }
  </code></pre>
  
  <p>// ApiCall</p>
  
  <pre><code>getDefaultValues() {
      return this.http.get&lt;any&gt;(this.stockUrl + 'getSelectiveDeleteData');
  }
  </code></pre>