- From: Sean Hogan <shogun70@westnet.com.au>
- Date: Mon, 17 Jun 2013 10:34:03 +1000
- To: Anne van Kesteren <annevk@annevk.nl>
- CC: www-dom@w3.org
On 15/05/13 11:37 PM, Sean Hogan wrote: > (Posting this again because my copy-and-paste inserted hyperlinks the > first time) > > I'm perplexed by the second step of future wrapper callbacks: > > Set callback's `callback this value` to resolver's associated future. > > Assuming this results in the equivalent of: > > callback.call(future, value) > > then I can't work out the purpose. > Is there a use for calling `future.then()`, etc inside the callback? > > There is also a potential failure mode in the unlikely case that the > callback returns `this`, that is, returns the current future object. > The result would be the following: > > future.then(function() { return this; }); // returns future > > run the associated resolver's resolve() with future > > future has a `then` method so it is called with callbacks that > would run future's resolve and reject algorithms > > now future is still pending until those callbacks get called, but > they won't get called until future is resolved. Obviously this stalls > permanently. > > Again this scenario is unlikely, but it is another indicator to me > that the spec is wrong (has a typo?) In addition to the potential failure mode, *and* the lack of use-cases for this setting, the [DOMPromises polyfill](https://github.com/slightlyoff/Promises/blob/master/polyfill/src/Promise.js) also doesn't bind the callback to the associated future/promise (or anything for that matter). Is / was there a justification for this step? Sean
Received on Monday, 17 June 2013 00:34:28 UTC