title: RxJava2: Nested loops - Outer loop needs to know when inner loop completed
body: <p>I need some guidance for resolving the following requirement:</p>
  
  <p>I have a method that returns <code>Completable</code> and inside it has 2 loops which the outer loop should return <code>complete</code> only when 2 loops completed iterating all items.</p>
  
  <p>Here is my attempt:</p>
  
  <pre><code>private Completable myMethod(Snapshot snapshot, ...) {
    return Completable.create(emitter -&gt; {
      Flowable.fromIterable(DAYS)
      .flatMapSingle(day -&gt; Flowable.fromIterable(ISSUES)
          .filter(this::filterByDay)
          .count()
          .map(issueCount -&gt; snapshot.setIssueCount(issueCount))
      ).subscribe(next -&gt; {}, 
                  emitter::onError,
                  emitter::completed);
    });
  }
  </code></pre>
  
  <p>This doesn't do what I expect it to, since the outer loop  completes before the inner! they subscribed independently.
  How can I make this work so the method returns <code>Completable</code> only when both loops completed?</p>