title: JavaScript Library to Synchronize Events
body: <p>let's say I'm doing 3 ajax calls and I want to wait for the 3 calls to finish before doing something.</p>
  
  <p>Is there a library out there to synchronize multiple async events in JavaScript ? (using or not jQuery's event system)</p>
  
  <p>Ex.:</p>
  
  <pre><code>var sync = new syncLib();
  $('a1').click(sync.newListener());
  $('a2').click(sync.newListener());
  
  sync.wait(function(e1, e2) {
    // fired when both a1 and a2 are clicked or when 10 seconds have passed
    // e1 and e2 would have properties to know whether or not they timed out or not..
  }, 10 /* timeout */));
  </code></pre>
  
  <p>I have found this one: <a href="https://github.com/Ovea/js-sync/blob/master/README.md" rel="nofollow">https://github.com/Ovea/js-sync/blob/master/README.md</a>, but timeouts are not supported. (Let's say the second ajax call takes too long, I don't want my synchronization to be hung up, I want to set a 10 secs timeout)</p>
  
  <p>I know I can code something myself, but I'm just checking here (after googling for it)</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong>
  Since then I found async: <a href="https://github.com/caolan/async" rel="nofollow">https://github.com/caolan/async</a></p>