title: Angular 8 rxjs get values from multiple observables
body: <p>I am using rxjs switchMap to get the latest form value from a subject, set a local variable and then perform a query based on that value.</p>
  
  <p>Long story short I am populating select box options based on the current value of the form.</p>
  
  <pre><code>  // Get current value of Record Form
    this.recordFormService.recordForm$
      .pipe(
        switchMap(recordForm =&gt; {
          // Get current Product Owner on Record Form
          this.currentProductOwner = recordForm.value.ProductOwner;
  
          // Search People
          return this.recordsApiService.searchPeople$(this.currentProductOwner);
        }),
        catchError(err =&gt; {
          console.error(`get recordForm$ failed ${err}`);
          return throwError(err);
        })
      )
      .subscribe(results =&gt; {
        // Set Product Owners select box options
        this.productOwners = results.data;
      });
  </code></pre>
  
  <p>This is all working properly.</p>
  
  <p>However, I also need to perform the same exact logic when a specific form value changes.</p>
  
  <pre><code>// Run the same logic when the ProductOwner value changes
  this.parentFormGroup.controls['ProductOwner'].valueChanges.subscribe(val =&gt; {});
  </code></pre>
  
  <p>I tried putting the combineLatest operator at the top, however that only resolves when both observables have emitted at least one value.</p>
  
  <p>The <code>valueChanges</code> observable may not necessarily ever change, but recordFormService.recordForm$ will run at least once when the page is loaded. </p>
  
  <p>Note: The result of the <code>valueChanges</code> observable is a string and the result of the <code>recordForm$</code> observable is a FormGroup object, they need to be processed entirely differently.</p>
  
  <p>What operator can I use to achieve this requirement?</p>
  
  <pre><code>// Get latest value of all observables
  combineLatest(
    this.parentFormGroup.controls['ProductOwner'].valueChanges,
    // Get current value of Record Form
    this.recordFormService.recordForm$
  )
  .pipe(
    switchMap(recordForm =&gt; {
      // Get current Product Owner on Record Form
      this.currentProductOwner = recordForm.value.ProductOwner;
  
      // Search People
      return this.recordsApiService.searchPeople$(this.currentProductOwner);
    }),
    catchError(err =&gt; {
      console.error(`get recordForm$ failed ${err}`);
      return throwError(err);
    })
  )
  .subscribe(results =&gt; {
    // Set Product Owners select box options
    this.productOwners = results.data;
  });
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I also tried <code>merge</code>. However the results of both observables are entirely different (one is a formGroup and one is a string) and they both need to be processed differently.</p>
  
  <pre><code>// Get latest value of all observables
  merge(
    this.parentFormGroup.controls['ProductOwner'].valueChanges,
    // Get current value of Record Form
    this.recordFormService.recordForm$
  )
  </code></pre>