Bluebird verspricht - wie explode ein array, dann auf Karte?

Wenn ich habe ein array:

['one.html','two.html','three.html']

wie könnte ich explodieren, das array, tragen Sie eine Kette von Versprechungen, dann kombinieren Sie es wieder zusammen? Im moment mein code ist so:

Promise.map(['one','two','three'], function(i) {
    dbQuery('SELECT ' + i);
}).then(function(results) {
    //This has an array of DB query results
});

Ich mir vorstelle, so etwas wie:

Promise.map(['one','two','three'], function(i) {
    dbQuery('SELECT ' + i);
})
.explode()
.then(function(result) {
    //Individual result
})
.combine()
.then(function(results) {
    //Now they're back as an array
});

Nun, ich weiß, Bluebird nicht diese Funktionen, so Frage ich mich, was das richtige Versprechen-y-Weg ist, dies zu tun?

InformationsquelleAutor Alastair | 2014-06-02
Schreibe einen Kommentar