title: Ensuring multiple subscriptions have completed before condition is checked
body: <p>I am using ngrx and I want to ensure that both subscriptions in my ngOnInit() are completed before I check conditions and invoke methods based on the conditions.</p>
  
  <p>My code looks like below:</p>
  
  <pre><code>ngOnInit(){
  
         this.status$ = this.store.pipe(
           takeWhile(()=&gt; this.isAlive),
           select(Selectors.getStatus)
         );
  
        this.process$ = this.store.pipe(
           takeWhile(()=&gt; this.isAlive),
           select(Selectors.getProcess)
         );
  
         this.status$.subscribe(status =&gt; {
            this.staus = staus;
  
            this.status$.subscribe(process=&gt; {
            this.process= process;
  
            if(!this.process.someBooleanProperty &amp;&amp; this.status.success){
                callMethodA();
            }else if(!this.process.someBooleanProperty &amp;&amp; this.status.error){
                callMethodB();
            }
         });
  });
  </code></pre>
  
  <p>I want to ensure that before I test my condition the status$ has completed so I put process$ subscription inside status$ subscription.</p>
  
  <p>I was looking for ways to improve this and if there are some operators which ensures that both subscription are completed before the condition is evaluated. I came across forkJoin operator in RxJs
  and refactored the code using it as below:</p>
  
  <pre><code>ngOnInit(){
  
     forkJoin(
         this.status$.pipe(takeWhile(()=&gt; this.isAlive)).pipe(tap(status =&gt; this.status = status)),
         this.process$.pipe(takeWhile(()=&gt; this.isAlive)).pipe(tap(process=&gt; this.process= process))
     ).susbscribe(() =&gt; {
         if(!this.process.someBooleanProperty &amp;&amp; this.status.success){
            callMethodA();
        }else if(!this.process.someBooleanProperty &amp;&amp; this.status.error){
            callMethodB();
        }
     }); 
  }
  </code></pre>
  
  <p>The above code using forkJoin doesn't work and debugger doesn't even reaches the line of codde having condition. As I am a backend developer learning fron-end, I am unable to understand the reason. Please can someone help me identify the  mistake in my approach. Also, is approach one bad ?</p>