3 ms·
Thanks for clarifying. This is a very neat way of removing what would be an extra level of nesting. It doesn't look like native promises support this unfortuna
by csytan 11y ago
Thanks for clarifying. This is a very neat way of removing what would be an extra level of nesting.
It doesn't look like native promises support this unfortunately:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Another nitpick I have with native promises is that they require an extra level of nesting to get the resolve callback.
// How it is now
new Promise(function(resolve, reject) {
resolve('done');
});
// vs. What most libraries implement
var p = new Promise();
p.resolve(function() {
return 'done';
});
- inglor 11y agoBoth parts are incorrect, the native way is `Promise.resolve('done')`. As for .call - native promises let you subclass them. If you have a promise enabled environment you can use generators anyway. I used Q's syntax because that's what OP used. Regardless - nice comment.