W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2013

Re: [futures] Add convenience functions for immediate/canceled promises

From: Mounir Lamouri <mounir@lamouri.fr>
Date: Thu, 18 Apr 2013 17:26:27 +0200
Message-ID: <517010A3.4040403@lamouri.fr>
To: www-dom@w3.org
On 12/04/13 20:10, Tab Atkins Jr. wrote:
> On Thu, Apr 11, 2013 at 4:57 PM, Domenic Denicola
> <domenic@domenicdenicola.com> wrote:
>> The conventional name for these two methods would be Future.resolve and Future.reject. The implementation would be
>> Future.resolve = (x) => new Future(({ resolve }) => resolve(x));
>> Future.reject = (reason) => new Future(({ reject }) => reject(reason));
>> This has the added benefit of using "resolve" semantics, i.e. assimilating thenables (including existing promises on the web, like jQuery promises).
> Now that I've actually learned the difference between accept() and
> resolve(), I'd prefer that all three of the resolution methods exist
> as statics on the Future interface.  You don't always want resolve
> semantics.

That would break the current barrier there is between the Future creator
and the Future users: only the creator of a Future can mark it as
resolved. Allowing any one to mark a Future as resolved might be a bit
painful in some cases for a benefit that doesn't seem obvious to me.

Received on Thursday, 18 April 2013 15:26:50 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:20 UTC