title: Angular 4 setTimeout() with variable delay and wait
body: <p>I have a list of events with <code>timestamp</code>. 
  What I want is to display the events based on the <code>timestamp</code>: </p>
  
  <p>To add a delay: </p>
  
  <pre><code>delay = timestamp(t+1) - timstamp(t)
  </code></pre>
  
  <p>I know this doesn't work well with <code>setTimeout</code>, but there is an workaround, if the timeout is constant, in my case is not. </p>
  
  <p>Is it possible to make the next <code>setTimeout()</code> wait for the previous one? To be specific, if the first <code>setTimeout()</code> has a 5 second delay and the second one has 3 seconds, the second one will appear first. I want them to be in the same order but execute one after the other.</p>
  
  <p>This example works for a constant delay, but I want to calculate the delay based on the information I take iterating the list. </p>
  
  <pre><code>for (i = 1; i &lt;= 5; ++i) {
    setDelay(i);
  }
  
  function setDelay(i) {
    setTimeout(function(){
      console.log(i);
    }, 1000);
  }
  </code></pre>