title: Spring Webflux - how to retrieve value from Mono/Flux multiple times without making multiple calls to get those Mono/Flux
body: <p>I'm using Spring Webflux &amp; reactor, Java 11, Spring boot 2.4.5, Spring 5.3.6 versions for this reactive application. <br>
  <strong>Use case:</strong>  <br>
  I need to make a call to API and get data from it. From this data I take uniqueId and then call bunch of API's to get other data, and then finally combine all this data to new Object and return. <br>
  Example code:</p>
  <pre><code>Mono&lt;Response&gt; 1stAPIResponse = 1stAPI.callMethod(eventId); // response object has ProductId, and other details.
  Mono&lt;List&lt;String&gt;&gt; productIds = 1stAPIResponse.map(Response::ProductId).collect(Collectors.toList());
  
  Mono&lt;2ndAPIResponse&gt; 2ndAPIResponse = productIds.flatMap(ids -&gt; 2ndAPI.callMethod(ids));
  Mono&lt;3rdAPIResponse&gt; 3rdAPIResponse = productIds.flatMap(ids -&gt; 3rdAPI.callMethod(ids));
  ...
  
  1stAPIResponse.foreach(response -&gt; {
      FinalResponse.builder()
      .productId(response.productId)
      .val1(2ndAPIResponse.get(response.productId))
      .val3(3ndAPIResponse.get(response.productId))
      . ...
      .build()});
  </code></pre>
  <p>Here the problem is, when ids are passed to 2ndAPI, 3rdAPI,... method, it makes call to 1stAPI and get the data each time. And finally when creating object it makes another call to 1st API. In this example it makes total of 3 calls.</p>
  <p>How can I avoid similar multiple calls from occurring?</p>
  <p>One way to avoid this is, I can make 1stAPI call blocking but is it correct? doesn't it defeat non-blocking style of coding? <br>
  Ex: <code>Response 1stAPIResponse = 1stAPI.callMethod(eventId).toFuture().get();</code></p>
  <p>How can I write a correct reactive program (without blocking) but still make only one call to 1stAPI?</p>
  <p>Let me know for any questions.</p>