Re: Futures

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 }

Received on Friday, 26 April 2013 18:04:06 UTC