title: R Shiny + Future + Plumber
body: <h2>Preamble</h2>
  <p>Inspired by the presentation by Barret Schloerke at studio::global(2021) (I will add the link as soon as it becomes available), I tried to implement an app to see the differences between using <code>{future</code>}, <code>{plumber}</code>, both or none into a Shiny app running a sequence of fast-slow-slow-fast computations (both on distinct output and in a sequence within the same one).</p>
  <h2>Gist</h2>
  <p>You can find <a href="https://gist.github.com/CorradoLanera/a3d39f35c5d8fa91297f0974e8b820af" rel="nofollow noreferrer">here</a> my attempt, including the <code>app.R</code> Shiny app and the <code>plumber.R</code> APIs.</p>
  <h2>Results</h2>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>execution selected (5 s for &quot;slow&quot;)</th>
  <th>result</th>
  <th>expectation</th>
  <th>comments</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Standard run</td>
  <td>~20 seconds before anything appear, next everything appears in the same moment</td>
  <td>~20 seconds, appearing sequentially somehow</td>
  <td>Why did not appear sequentially?</td>
  </tr>
  <tr>
  <td><code>{future}</code> only</td>
  <td>~5 seconds before anything appear, next everything appears in the same moment</td>
  <td>~20 with &quot;first fast&quot; and &quot;second fast&quot; appearing almost immediatly and next (~5) &quot;first slow&quot; or &quot;second slow,&quot; next (~10) the other, and finally (~20) &quot;Sequential&quot;)</td>
  <td>I would expect that something similar to what happened here for the combined type of run... how is possible that &quot;sequential&quot; completed in 5 seconds???</td>
  </tr>
  <tr>
  <td><code>{plumber}</code> only</td>
  <td>same as the standard run (r should remain busy until each API call would be resolved, right?)</td>
  <td>same time (~20) but appearing sequentially some how</td>
  <td>why shiny rendered everything the same time?</td>
  </tr>
  <tr>
  <td><code>{future}</code> and <code>{plumber}</code></td>
  <td>same as the standard run</td>
  <td>I do not expect this at all!, What I expected here is to have &quot;<em>_fast&quot;s appearing immediately, &quot;</em>_slow&quot;s quite the same time after ~5 seconds, and &quot;sequential&quot; after ~10 seconds from the start (i.e., ~10 seconds overall)</td>
  <td>I am totally confused here :-(</td>
  </tr>
  </tbody>
  </table>
  </div><h2>Doubts</h2>
  <p>One of the main things I did not understand is why when activating <code>{future}</code> (both with or without <code>{plumber}</code>), &quot;first fast&quot; does not appear immediately. And in general, why the output does not appear in a single sequence when <code>{future}</code> is not involved. And how is it possible that with <code>{future}</code> alone, &quot;sequential&quot; stay ~5 seconds?</p>
  <p>So, clearly, I made something the wrong way, and I do not understand something correctly.</p>
  <h2>Questions</h2>
  <p>Can someone help me understand where/what (and maybe try to infer &quot;why&quot;) I made the app wrong, and/or the API wrong, or their interaction wrong?</p>
  <p>Thank you,
  Corrado.</p>