On Nov 17, 2016, at 11:46 PM, Alex Harui <aha...@adobe.com> wrote: > > > On 11/17/16, 11:21 AM, "Harbs" <harbs.li...@gmail.com> wrote: > >>> It looks like Promise does implement Ithenable. >> Yes. I know. >> >> I did not word that very well. I’m not sure what I meant. I was probably >> talking about the AS3 implementation. I’m currently thinking that Promise >> should implement IPromise which inherits from IThenable and ICatchable. >> Is there a way of declaring static functions in interfaces (i.e. >> IPromise.resolve(), IPromise.reject(), IPromise.all())? > > Static functions? Why wouldn't they be instance methods. Interfaces in > AS3 can only handle public instance functions.
Promise has 4 static methods which return Promise objects: all(), race(), reject() and resolve().[1] The most important of these is probably reject() which is the only way I know of to force a catch in the middle of a promise chain. all() is also very useful. The method of these which is problematic when using the externs is resolve() because it returns an Object instead of a Promise.\ > >> >> I’m not sure what you mean about not using es6. The definitions seem to >> be picked up from there. > > Interesting. I thought we weren't using ES6. Does that mean that to use > Promise in the browser we have to do something to turn on ES6 support? Not for most browsers. The evergreen browsers all have Promise built in as a Global object.[2] I.E. needs a polyfill. [1]https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise [2]http://caniuse.com/#feat=promises