Futures

Kevin Smith zenparsing at gmail.com
Fri Apr 26 11:03:39 PDT 2013


The current DOM spec, in code:

    Future.resolve(1).then(value => {

        value === 1;

        // Return a non-promise
        return 2;

    }).then(value => {

        value === 2;

        // Return a promise for a non-promise
        return Future.resolve(3);

    }).then(value => {

        value === 3;

        // Return a promise that *resolves* to a promise
        return Future.resolve(Future.resolve(4));

    }).then(value => {

        value === 4;

        // Return a promise *whose value* is a promise
        return Future.accept(Future.resolve(5));

    }).then(value => {

        value !== 5;

        // Return the value-which-is-a-promise
        return value;

    }).then(value => {

        value === 5;
    });

As a gist: https://gist.github.com/zenparsing/5469130

Please let me know if I made a mistake with the above.

{ Kevin }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130426/18e238f5/attachment.html>


More information about the es-discuss mailing list