- then() is to map() as done() is to forEach()
- Error handling
- Now you have to teach when to use each method
- No clear consensus in A+
- It doesn't look like DOM Promises will include it at the moment
One option is to throw/log when a promise is rejected and no rejection callbacks were added to it. Throwing doesn't sound like a good idea because of Promise.reject(foo)
. We could make use of the debug
filter in YUI.
Another option is to do something a lot more complicated and try to do static analysis to figure out if an error ir never handled.
- DOM Promises can't be subclassed. In the future we'll possibly (probably?) have to do:
let resolver = Symbol();
class MyPromise extends Promise {
static [@@create]() {
var promise = new Promise(r => this[resolver] = r);
promise.__proto__ = MyPromise.prototype;
return promise;
}
constructor(...args) {
// initialize `this`
}
}
- Subclassing looks a bit like an anti-pattern.
AbortableProgressPromise
. It's possible we want promises to be a behavior of an object, not a type. Composition over inheritance
There's been a lot of discussion about monads vs promises. Promises are almost monads. ES6 will probably introduce two changes:
flatMap
a method that does satisfy to the monad laws (allows promises for promises)- Promises will have a new
accepted
state when resolved to other promises
This conflicts with a change in the Pull Request that treats promises different from thenables.
Performance analysis show no dramatic gains. Synchronous resolution is something we should add at some point, the DOM does it.
- Include
done
or not include it - Work on a polyfill or not
- Notify on unhandled rejected promises
- Drop the pull request and start a new one with safe changes (only API additions in DOM, performance improvements)
Can we link to this for the show notes & YUI Weekly? It's marked secret, so just wanted to double-check. Nice work!