Closed ryandbair closed 10 years ago
I just added a Promise.all()
utility function which addresses this need similarly to how the various JavaScript Promises/A+ implementations have.
Promise
.all( [ promise1, promise2, promise3 ] )
.then( function ( fulfilledValues:Array ):int {
// do stuff with results
} );
NOTE: The parameter passed to Promise.all()
can be an Array of values and/or Promises, or even a Promise of an Array of values and/or Promises.
You might also be interested in the new spread
utility function, too:
import com.codecatalyst.util.spread;
// ...
Promise
.all( [ promise1, promise2, promise3 ] )
.then( spread( function( value1:int, value2:int, value3:int ):int {
// do stuff with results
} ) );
I came across a case where I need to combine multiple Promises into one, similar to other Promise implementation's zip feature (such as Scala's).
I put together a solution which can be used like so:
I didn't see anything like this in the Promises/A+ specs, but I think it would be useful to many people. If its something you would like to include, I can clean up the code and submit a pull request.
Interested?