Created
May 29, 2015 11:26
-
-
Save cybic/a35daf1ef5628846328d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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