cujojs / when

A solid, fast Promises/A+ and when() implementation, plus other async goodies.
Other
3.44k stars 396 forks source link

variadic when.fold? #338

Closed courajs closed 10 years ago

courajs commented 10 years ago

Feels a bit arbitrary to limit promise.fold to folding one arg in. Would it make sense to expand that?

briancavalier commented 10 years ago

Hey @FellowMD, a single accumulator is the usual signature for a fold (reduce, reduceRight, foldl, foldr, etc.), so I'd like to stick to that for promise.fold. However, there are a couple of other really nice ways to deal with variadic promises, most notably when.try and the when.join().spread() pattern. For example:

var resultPromise = when.try(f, p1, p2, p3);
function f(x, y, z) {
   return x+y+z;
}
briancavalier commented 10 years ago

Closing, as there are other options for handling variadic number of promises. Feel free to continue the discussion, though.