Create a deferred for all arguments independently and exposes iterative methods, such as doneEach and failEach as well as a deferred for all objects as a set.
Note - use with underscore requires the underscore.Deferred plugin by Sam Breed.
Download the production version or the development version.
$.whenSet( anAsyncFunction, anotherAsyncFunction )
.doneEach( function( result ){
console.log( result, ' just finished' );
})
.done( function( resultA, resultB ){
console.log( 'all done!' );
});
_.whenSet( anAsyncFunction, anotherAsyncFunction )
.doneEach( function( result ){
console.log( result, ' just finished' );
})
.done( function( resultA, resultB ){
console.log( 'all done!' );
});
The returned promise will has the doneEach
, failEach
, alwaysEach
, pipeEach
exposed
as well as putting the arguments onto one promise as an array, like [0] => arg1, [1] => arg2,
etc.
Here's a demo: http://jsfiddle.net/danheberden/YRB4P/
366 bytes min'd and gzip'd
Moar unit tests
v1.0.0 - used grunt to make awesome
v0.0.1 - initial release
Copyright (c) 2012 Dan Heberden Licensed under the MIT license.