Adapters needing `fulfilled(Value)` and `rejected(reason)` methods
Closed this issue · 4 comments
ForbesLindesay commented
Couldn't these just be implimented from pending and tested that way, reducing the number of methods to be implemented in adapters:
exports.fulfilled = function (value) {
let {promise, fulfill} = exports.pending();
fulfill(value);
return promise;
};
exports.rejected= function (value) {
let {promise, reject} = exports.pending();
reject(value);
return promise;
};
(obviously you'd need to convert that to ES5 😄)
domenic commented
You're right, of course. The only objection is that promise libs might not get as much test coverage, if their create-fulfilled and create-rejected functions don't internally work by creating a pending first. I could go either way.
briancavalier commented
Can/should we provide default implementations for fulfilled and rejected for adapters that don't explicitly provide them? I.e. but still allow an adapter to provide them if it wants to?
domenic commented
Ooh, I kind of like that idea. Get better coverage if you want it, but not necessary.
ForbesLindesay commented
I like that too