title: Conditionally combine Mono with Flux
body: <p>I need to combine the results from two reactive Publishers - Mono and Flux. I tried to do it with <code>zip</code> and <code>join</code> functions, but I was not able to fulfil two specific conditions:</p>
  
  <ol>
  <li>result should contain as many element as Flux emits, but corresponding Mono source should be called only once (this condition alone can be implemented with <code>join</code>)</li>
  <li>when Flux is empty, then chain should complete without waiting for Mono element</li>
  </ol>
  
  <p>The solution for the first condition is presented in the <a href="https://stackoverflow.com/questions/59787201/combine-mono-with-flux">Combine Mono with Flux</a> entry (pasted below). But I was not able to achieve second condition without blocking the chain - and that I would like to avoid. </p>
  
  <pre><code>Flux&lt;Integer&gt; flux = Flux.concat(Mono.just(1).delayElement(Duration.ofMillis(100)),
          Mono.just(2).delayElement(Duration.ofMillis(500))).log();
  
  Mono&lt;String&gt; mono = Mono.just("a").delayElement(Duration.ofMillis(50)).log();
  
  List&lt;String&gt; list = flux.join(mono, (v1) -&gt; Flux.never(), (v2) -&gt; Flux.never(), (x, y) -&gt; {
      return x + y;
  }).collectList().block();
  
  System.out.println(list);
  </code></pre>