-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to check if something is a Future #40
Comments
And many implementations don't support |
I'm not tied to the I know that @dherman also had concerns along these lines. |
I'm not sure DOMFuture.prototype.then = function (
onaccept = function (x) { return x; },
onreject = function (x) { throw x; }
); and of course that has |
Put another way, the number of "required" parameters is zero, not two, and generally a function's There's also compatibility with the many implementations that implement progress as the third argument, e.g. Q, WinJS, and when. They all have |
Generally there are two approaches here: branding and no-branding. BrandingBranding was considered in promises-aplus/promises-spec#2 and generally rejected, with @wycats in favor and myself slightly in favor, but most others opposed. The basic idea is that we "brand" Promises/A+-compliant promises e.g. with Note that ES6 symbols are not a great solution here, as the non-collision benefits are not important and the symbol would need to be system-supplied for interoperability, in which case a symbol and a string are equivalent. It would mean that the following code does not work: var promise = aplusCompliantPromise.then(() => jQueryPromise);
var promise = new Promise(resolve => resolve(jQueryPromise)); i.e. the promise becomes fulfilled with Instead you need to provide an assimilation function, e.g. var promise = aplusCompliantPromise.then(() => Promise.from(jQueryPromise));
var promise = new Promise(resolve => resolve(Promise.from(jQueryPromise))); Implementations would often alias this as e.g. Still, it breaks generic interoperability, and would be a major backward-incompatible change for most promise libraries in use today. I am not sure whether implementers would be willing to shoulder this change. No BrandingNo branding means we use the current Promises/A+ This forces you to wrap any non-promisey thenables, e.g. var promise = aplusCompliantPromise.then(() => [nonPromiseyThenable]);
var promise = new Promise(resolve => resolve([nonPromiseyThenable]));
promise.then(([nonPromiseyThenable]) => { ... }); One major hazard I see is that it further exacerbates the already-big dangers of treating objects as hashes, especially for user input. E.g. you could envision a user crashing your server by adding a query string |
@domenic : hadn't considered the default arg situation, but I honestly don't feel that's apropos. Libraries will do what they need to to fit our contract. That's independent from coming up with a good contract. I'll respond in #41, but I'm not hopeful about branding. It ends up at cached duck-typing for anything that needs to work cross-frame. |
@slightlyoff more or less agree. But, eventually you'll want to spec |
IDL defines length and if there's optional arguments it will indeed not count those. |
I've removed the |
Hi!
I noticed the polyfill is checking for the existence of both the
then
anddone
functions in an object. Why check fordone
? Pretty much every implementation out there is only checking forthen
. Examples:The text was updated successfully, but these errors were encountered: