On Fri Feb 7 12:14 PM, Tab Atkins Jr. wrote:
> >
> > From a user perspective, can someone explain what chain() does?
> 
> .chain returns what is directly inside the promise, without doing any 
> additional
> magic.  This is different from .then, which "flattens"
> promises.
> 
> For a more concrete example, assume that "x" is a Promise<Promise<integer>>.
> That is, it's a promise, holding a promise, holding an integer.  
> x.chain(arg=>"arg is
> a Promise<Integer>"), x.then(arg=>"arg is an Integer").
> 

Thoughts on adding options/flags to then()?
e.g.
x.chain  equivalent to  x.then(promise, {unwrap: false});

Promises.all() could be similarly augmented to support serial execution. 
The api signatures become ~

Promise.prototype.then ( onFulfilled , onRejected|PromiseOptions , 
PromiseOptions )
Promise.all ( iterable , PromiseIterateOptions )

Defaults:
PromiseOptions = {
   unwrap: true
}
PromiseIterateOptions extends PromiseOptions {
   serial: false
}

Don't have convincing use case but can pass options to then() during iteration:
Promises.all([a,b,c], {unwrap: false});


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to