title: How to dynamically add functions to the queue?
body: <p>I have <code>render(value)</code> function that I'm calling multiple times with different parameters. I need to chain calls to this function, so that it starts execution only when previous call has finished.</p>
  
  <p>The function I need to chain returns a promise:</p>
  
  <pre><code>function render(value){
     var deferred = $q.defer();
  
     /* Some logic here */
  
     return deferred.promise;
  }
  </code></pre>
  
  <p>What should I place here?</p>
  
  <pre><code>function onClick(value){
     /*
         Add render(value) to the queue. And start execution if queue is empty
     */
  }
  </code></pre>