al6x / synchronize

Write asynchronous code as if it's synchronous
http://alexeypetrushin.github.com/synchronize
316 stars 57 forks source link

sync.parallel() should be a noop if sync.defer not called #25

Closed bradvogel closed 9 years ago

bradvogel commented 9 years ago

My code uses a loop inside sync.parallel():

    var responses = sync.await(sync.parallel(function() {
      myArray.forEach(function(item) {
        asyncFn(item, sync.defer());
      });
    }));

I noticed that when myArray is length 0 that sync.await never returns. This seems like a bug. Shouldn't sync.parallel know that sync.defer wasn't called inside of it and just be a noop?

al6x commented 9 years ago

Thanks, yep, looks like a bug, it should know that there was no call.