title: Combine values of multiple kotlin flows even if only some emit values
body: <p>I am trying to combine multiple flows even if some of them don't emit.</p>
  <p>I tried to create a reproducible snippet to be able to illustrate better what I want to achieve. Below you can see my 2 attempts, but non of them work as expected.</p>
  <pre><code>fun main() {
  
      val ids = (1..5)
      val idsFlow = ids.asFlow()
  
      //option 1
      println(&quot;Option 1&quot;)
      val valuesFlow = idsFlow.map { id -&gt;
          getFlowById(id)
      }.flattenMerge()
  
      runBlocking {
          valuesFlow.collect { listOfItems -&gt;
              println(&quot;Value received $listOfItems&quot;)
          }
      }
  
      //option 2
      println(&quot;Option 2&quot;)
      val valuesFlowList = ids.map { id -&gt;
          getFlowById(id)
      }
  
      runBlocking {
          combine(valuesFlowList) { itemsLists -&gt;
              itemsLists.flatMap { it }
          }.collect { listOfItems -&gt;
              println(&quot;Value received $listOfItems&quot;)
          }
      }
  
  }
  
  fun getFlowById(id: Int): Flow&lt;List&lt;Int&gt;&gt; = flow {
      println(&quot;Flow for id $id&quot;)
      if (id % 2 == 0) {
          emit(listOf(id, id))
      }
  }
  </code></pre>
  <p>And the output of this is:</p>
  <pre><code>Option 1
  Flow for id 1
  Flow for id 2
  Flow for id 3
  Flow for id 4
  Flow for id 5
  Value received [2, 2]
  Value received [4, 4]
  Option 2
  Flow for id 1
  Flow for id 2
  Flow for id 3
  Flow for id 4
  Flow for id 5
  
  Process finished with exit code 0
  </code></pre>
  <p>But what I would like to end up with is:</p>
  <pre><code>Value received [2, 2, 4, 4]
  </code></pre>
  <p>I believe I am missing something, but not sure what. If someone could point me to the right direction it would be really appreciated.</p>