when.settle, promises, , , , , .
var arrayOfPromises = array.map(testMapper);
when.settle(arrayOfPromises).then(function(descriptors){
descriptors.forEach(function(d){
if(d.state === "rejected"){
} else{
console.log("Successful!", d.value);
}
})
});
:
. , , , . .
, .
, Bluebird promise-using, , .
:
using(pool.getConnectionAsync().disposer("close"), function(connection) {
return connection.queryAsync("SELECT * FROM TABLE");
}).then(function(rows) {
console.log(rows);
});
:
var a = Promise.cast(externalPromiseApi.getResource1()).disposer("close");
var b = Promise.cast(externalPromiseApi.getResource2()).disposer("close");
using(a, b, function(resource1, resource2) {
})