title: ngrx - for loop - take next element once process for current element is completed
body: <p>sorry for sill question. I have a requirement where user has to finish 6 steps to complete 1 activity. If user is clicking on URL of step 6 then I first I have to check whether they have finished previous 5 steps. If not then I have to indicate which steps user has completed and which are pending. For the pending one I am also adding URL so user can easily redirect.</p>
  
  <p>The problem is, I am iterating though each step but because of NG RX it's not waiting for the Action to be completed and moving to the next step. I am not able to identify whether previous steps really finished or not.</p>
  
  <p>I am using NG RX Action, Reducer and Effect technology. Is there anyway I can wait in for loop for first action completion. Once first action completed then and then take second element from the array.</p>
  
  <pre><code>// This is part of code in effect file.    
  const steps = [Step.Step1, Step.Step2, Step.Step3]
  
      // It should take next element once evaluation of step1 is completed.
      steps.every((currentStep: Step) =&gt; {
                          currentDependentStep = currentStep;
                          switch (currentStep) {
                              case Step.Step1:
                                  this.store.dispatch(new fromSomeAction.SomeAction1);
                                  this.store.dispatch(new fromSomeAction.SomeAction2);
  
                                  this.store.combineLatest(
                                      this.store.select(fromApp.getData1),
                                      this.store.select(fromApp.getData2)
                                  ).first(([payload, data1, data2]) =&gt; !!data1 &amp;&amp; !!data2)
                                      .subscribe(([payload, data1, data2]) =&gt; {
                                          // It should not take second element till I get below result whethere it is completed or not.
                                          isCompleted = &lt;check for some condition&gt;;
                                      });
                                  break;
                              case Step.Step2:
                                  this.store.dispatch(new fromSomeAction.SomeAction1);
                                  this.store.dispatch(new fromSomeAction.SomeAction2);
  
                                  this.store.combineLatest(
                                      this.store.select(fromApp.getData1),
                                      this.store.select(fromApp.getData2)
                                  ).first(([payload, data1, data2]) =&gt; !!data1 &amp;&amp; !!data2)
                                      .subscribe(([payload, data1, data2]) =&gt; {
                                          isCompleted = &lt;check for some condition&gt;;
                                      });
                                  break;
                              case Step.Step3:
                                  this.store.dispatch(new fromSomeAction.SomeAction1);
                                  this.store.dispatch(new fromSomeAction.SomeAction2);
  
                                  this.store.combineLatest(
                                      this.store.select(fromApp.getData1),
                                      this.store.select(fromApp.getData2)
                                  ).first(([payload, data1, data2]) =&gt; !!data1 &amp;&amp; !!data2)
                                      .subscribe(([payload, data1, data2]) =&gt; {
                                          isCompleted = &lt;check for some condition&gt;;
                                      });
                                  break;
                                  break;
                              default:
                                  isCompleted = false;
                                  break;
                          }
  
                          return !isCompleted;
                      });
  
                      // Call completed action with payload based on isCompleted
  </code></pre>
  
  <p>Note: Sorry I don't have actual code to share here.</p>