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

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

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 11 Apr 2013 18:02:42 -0700
Message-ID: <CAAWBYDAFDbEfPN4iWsy6R3ZXT6ToG_Nbu4FSfUOMJM3ourf-BQ@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: Brandon Wallace <brandon.wallace@yahoo.com>, "www-dom@w3.org" <www-dom@w3.org>
On Thu, Apr 11, 2013 at 4:57 PM, Domenic Denicola
<domenic@domenicdenicola.com> wrote:
> Hi all,
>
> 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).

Ah, I wasn't aware there was a set of more conventional names.  I like
that this plays directly into the existing resolver method naming.

~TJ
Received on Friday, 12 April 2013 01:03:30 UTC

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