Futures

Tab Atkins Jr. jackalmage at gmail.com
Fri Apr 26 11:10:49 PDT 2013


On Fri, Apr 26, 2013 at 11:03 AM, Kevin Smith <zenparsing at gmail.com> wrote:
> The current DOM spec, in code:

Or, much more simply:

* Future.accept takes a Foo and returns a Future<Foo>.
* Future.resolve takes either a Foo or a Future<Foo>. In either case,
it returns a Future<Foo>.
* In Future.then(cb), the cb is expected to have the signature (Foo ->
Future<Foo>). It has some extra magic that allows you to return a
plain Foo, and treats it the same as if you returned a Future<Foo>.
Effectively, this means that it passes the return value through
Future.resolve() to normalize it into a Future<Foo>.
* You can totally make nested Futures deliberately by doing something
like "Future.accept(Future.accept(5))".

~TJ


More information about the es-discuss mailing list