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

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