Skip to content

Instantly share code, notes, and snippets.

@cybic
Created May 29, 2015 11:26
Show Gist options
  • Save cybic/a35daf1ef5628846328d to your computer and use it in GitHub Desktop.
Save cybic/a35daf1ef5628846328d to your computer and use it in GitHub Desktop.
var Promise = require('es6-promise').Promise;
function test(a) {
return new Promise( function(resolve, reject){
console.log( 'Running %s', a );
setTimeout( resolve.bind( this, 'dønn ' + a ), 5000);
});
}
var set = [];
for ( var i = 0; i < 10; i++ ) {
set.push( test( 'instance' + i ) );
}
setTimeout( function() {
console.log( 'Starting all()' );
Promise.all( set )
.then( function( res ) {
console.log( 'All done %s', res );
});
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment