On Fri, Oct 21, 2011 at 10:46 AM, Mark S. Miller <[email protected]> wrote:
> On Fri, Oct 21, 2011 at 10:20 AM, John J Barton < > [email protected]> wrote: > >> >> >> In particular, Q simplifies joining parallel async operations (XHR, >> postMessages, 'load', 'progress' events). Of course it may well be that >> generators provide an elegant solution to this important problem, but I've >> not seen such examples. >> > > Have you seen > http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#q.race and > http://wiki.ecmascript.org/doku.php?id=strawman:concurrency#q.all ? If > these don't address the joining you have in mind, could you post some > examples? Thanks. > Unfortunately I was not able to follow the comments on that page. (These strawman pages are hard to follow because they describe new things using new terminology). This code seems to do what I intended: https://github.com/johnjbarton/Purple/blob/master/chrome/extension/pea.js#L114 The structure is: start A, start B, when A&B (start C, start D, when C&D (we win))); The code marches right but for me the key is being able to predict the relative order of the calls. Of course this particular example is not good for comparing different alternatives. I guess the biggest win for Q comes in unconventional cases where async is used for remote communications and such examples are currently complex. jjb
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

