Recently I was reviewing my code repository and the useless of Promise, I found
we have majorly 2 scenario to use Promise:
Just match the synchronous flow control, so then matches return and catch
matches catch
Use it for a yes-or-no scenario, this is what I’m confusing
For the 2nd scenario, a best example should be a confirm dialog, which returns
a Promise which resolves after user click the “YES” button and rejects after
the “NO” button is clicked, so the usecase could be:
var confirming = wairForUserConfirm('Continue to exit?');
confirming.then(exitApplication);
I see it a “reasonable” scenario, in this case the resolve means user resolves
your question and reject means user rejects, seems a good story up to now
The problem is, in such case we usually do not attach a catch to rejections,
once the global uncaught exception handling for promise is done, it may throw a
window.onerror message which is not expected
Therefore, I’d like to ask whether we should ONLY use Promise as a
return-or-throw synonyms, or we should use it in a yes-or-no scenario
Thanks
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss