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

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

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Thu, 11 Apr 2013 23:57:26 +0000
To: Brandon Wallace <brandon.wallace@yahoo.com>, Tab Atkins Jr. <jackalmage@gmail.com>, "www-dom@w3.org" <www-dom@w3.org>
Message-ID: <B4AE8F4E86E26C47AC407D49872F6F9F7D2DB887@BY2PRD0510MB354.namprd05.prod.outlook.com>
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).
Received on Thursday, 11 April 2013 23:58:16 UTC

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