Created
April 15, 2015 23:22
-
-
Save joepie91/2aafe9e4830e0d0c8171 to your computer and use it in GitHub Desktop.
Nested mapping in bluebird
This file contains 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("bluebird"); | |
Promise.try(function(){ | |
return getItemsSomehow() | |
}).map(function(topLevelItem){ | |
return Promise.try(function(){ | |
return doAsyncThingWith(topLevelItem); | |
}).map(function(childItem){ | |
return doOtherAsyncThingWithEach(childItem); | |
}); | |
}).then(function(finalResult){ | |
/* finalResult will contain an array of arrays, all of it asynchronously resolved. */ | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment