re: Limit concurrent asynchronous calls VIEW POST

TOP OF THREAD FULL DISCUSSION
re: This is really clever, but isn't the catch behaviour pretty dangerous? You wouldn't know if one of these async functions failed. Or am I missing so...
 

No, because the function returns p itself, not the chained promise. The caller can attach its own .catch() clauses to p.

As in,

function foo() {
    let p = Promise.reject();

    p.catch(() => console.log('gotcha'));

    return p;
}


let p = foo();

p.catch(() => console.log('gotcha again'))
 

Ah. I didn't realise you could catch a second time. Even cleverer then.

code of conduct - report abuse