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

[futures] Add convenience functions for immediate/canceled promises

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 11 Apr 2013 16:43:54 -0700
Message-ID: <CAAWBYDA9BEooNX9HMNBZ9deLs_mdpPe3vPCYNwzww8_1Ev4mSA@mail.gmail.com>
To: www-dom@w3.org
Task.js has two convenience functions, now(x) and never(), which
return a resolved or cancelled promise, respectively.  This is useful
when combining plain values with the promise algebra, so the
combinators don't need to ducktype their arguments to try and guess
whether they're a promise or a plain value.  (Plus, it lets you easily
create a promise which resolves to a promise and use it in the

Separately, there's been discussion over at the PromisesAPlus github
about more explicitly supporting the fact that promises are monadic,
by defining a point/pure/return function that just returns a "default"
(fulfilled) promise from a base value

Supporting these use-cases seem useful and simple.  We should add
Future.of(val) and Future.never() convenience static functions to the
Future interface.

Received on Thursday, 11 April 2013 23:44:41 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:02 UTC