On 11/17/16, 2:42 PM, "Harbs" <harbs.li...@gmail.com> wrote:

>
>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.\

MDN says resolve() returns a Promise.  So you could just modify the extern
to do so.

I'm not familiar with Promises.  Maybe they aren't type-safe?  It sounds
like some APIs that return a Promise may actually return a value in some
cases and maybe that's why the extern uses Object?

-Alex


Reply via email to