title: How do you chain dependent subscriptions that need multiple previous observables
body: <p>New to rxjs, looking for a good clean way to chain some observables/subscriptions.</p>
  <p>Here's some simple pseudocode I made to try to emulate what I'm trying to do.</p>
  <pre class="lang-js prettyprint-override"><code>class Baker implements OnInit {
  
    //functions, constructor, varibles, etc.
  
    ngOnInit(): void {
      this.myFridgeService.getDough().pipe(
        switchMap(dough =&gt; {
          return of(this.addToBowl(dough));
        }),
        switchMap(bowl =&gt; {
          this.myPantryService.getMnMs()
            .subscribe((mnms: Candy[]) =&gt; {
              this.bagOfMnMs = mnms; // will use later
              return of(mnms).pipe(filter(mnm =&gt; mnm.isGreen()));
            }); 
        }),
        switchMap(greenOnes =&gt; {
          return this.myMixerService.mix(bowl, greenOnes); // can I get bowl here somehow?
        }))
        .subscribe(cookie =&gt; {
          this.bake(cookie);
        },
          (error: HttpErrorResponse) =&gt; {
            console.error(error);
            this.serviceError = error;
          }
        );
    }
  }
  </code></pre>
  <p>I can't get bowl into myMixerService because it's from a previous switchMap, and as far as I know I can't pass along multiple returns.</p>
  <p>I could put the myMixerService call into the subscription event of myPantryService, which would look something like this</p>
  <pre class="lang-js prettyprint-override"><code>class Baker implements OnInit {
    ngOnInit(): void {
      this.myFridgeService.getDough().pipe(
        switchMap(dough =&gt; {
          return of(this.addToBowl(dough));
        }),
        switchMap(bowl =&gt; {
          this.myPantryService.getMnMs()
            .subscribe((mnms: Candy[]) =&gt; {
              this.bagOfMnMs = mnms; // will use later
              const greenOnes = of(mnms).pipe(filter(mnm =&gt; mnm.isGreen()));
              return this.myMixerService.mix(bowl, greenOnes);
            },
              (error: HttpErrorResponse) =&gt; {
                console.error(error);
                this.serviceError = error;
              });
        })
      ).subscribe(cookie =&gt; {
        this.bake(cookie);
      },
        (error: HttpErrorResponse) =&gt; {
          console.error(error);
          this.serviceError = error;
        }
      );
    }
  }
  </code></pre>
  <p>But I feel like putting that service call in a subscription event is an antipattern, and in fact part of the reason for switchMap in the first place. And that's besides the fact that it never returns back up to cookie</p>