endpoint.js
endpoint.js copied to clipboard
Easy way to resolve lots of strategies and return their results to the next then()
If I need to call a large amount of functions on an API, then do something after they're finished, it is nearly impossible to do this right now. Promise frameworks like Q have a 'q.all()' method that resolves once all the promises complete. It would be nice to have an easy to create strategy that can resolve all the given strategies, then send the ultimate results to another then() method.
Something like this:
res.then(function(matrix) {
strategies = [];
for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
strategies.push(api.matrix_set(matrix, i, j, i + j));
}
}
return facade.all(strategies);
})
.then(function(resultArray) {
...
});