Re: Promise.allSettled() - why string?

2020-04-17 Thread Jordan Harband
The iteration protocol has a boolean data property `.done` - I don't know
if anyone ever suggested some kind of `isDone()` method for that, and I
think the iteration protocol sets a precedent of the "tag" on the object
being a primitive.

On Fri, Apr 17, 2020 at 7:25 PM Felipe Gasper 
wrote:

> Hello,
>
> If it’s not too awkward of a question to ask: were object methods
> rather than string comparison considered for Promise.allSettled()?
>
> For example, if I write this:
>
> -
> Promise.allSettled(promises).then( results => {
> results.forEach( r => {
> if (r.status === "rejectd") {
> // Failure …
> }
> else {
> // Success!
> }
> } );
> } );
> -
>
> … the code won’t complain about the typo but instead just “do the wrong
> thing”.
>
> But, if the way to parse allSettled()’s resolution were object methods
> instead, it could be this:
>
> -
> Promise.allSettled(promises).then( results => {
> results.forEach( r => {
> if (r.isRejectd()) {
> // Failure …
> }
> else {
> // Success!
> }
> } );
> } );
> -
>
> … which will usefully cause an exception/rejection that pinpoints the
> problem in my code.
>
> Was this pattern perhaps considered and rejected? Or is there some
> liability to the object methods relative to the string comparison that I’m
> not seeing? If so, what was/is the rationale there?
>
> Thank you for your time!
>
> cheers,
> -Felipe Gasper
> ___
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss


Promise.allSettled() - why string?

2020-04-17 Thread Felipe Gasper
Hello,

If it’s not too awkward of a question to ask: were object methods 
rather than string comparison considered for Promise.allSettled()?

For example, if I write this:

-
Promise.allSettled(promises).then( results => {
results.forEach( r => {
if (r.status === "rejectd") {
// Failure …
}
else {
// Success!
}
} );
} );
-

… the code won’t complain about the typo but instead just “do the wrong thing”.

But, if the way to parse allSettled()’s resolution were object methods instead, 
it could be this:

-
Promise.allSettled(promises).then( results => {
results.forEach( r => {
if (r.isRejectd()) {
// Failure …
}
else {
// Success!
}
} );
} );
-

… which will usefully cause an exception/rejection that pinpoints the problem 
in my code.

Was this pattern perhaps considered and rejected? Or is there some 
liability to the object methods relative to the string comparison that I’m not 
seeing? If so, what was/is the rationale there?

Thank you for your time!

cheers,
-Felipe Gasper
___
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss