Re: [promises] resolver's resolved flag check on promise callback

Yutaka Hirano <[email protected]>
Newsgroups gmane.comp.web.dom.general
Message-ID <CABihn6E_CJWZU98V87nDcUTexgCrio8WmMazCE+tYti4HKkCXw@mail.gmail.com>
> What do you mean by 4.4?
Sorry, I meant the entry in resolver's resolve algorithm.

  4. If calling the [[Call]] internal method threw an exception, catch it
and run context object's reject with the thrown exception and the
synchronous flag if set.

> I think you're right that this is problematic, but it's not entirely
clear to me this solves it.
I think adding adhoc checks works, but doing the following will solve the
problem more cleanly.
 - Remove resolved flag.
 - Add "resolving" state.
 - fulfill algorithm (not fulfill method) does nothing if the promise's
state is not "pending" nor "resolving".
 - resolve algorithm (not resolve method) does nothing if the promise's
state is not "pending".
 - reject algorithm (not reject method) does nothing if the promise's state
is not "pending" nor "resolving".
 - resolve algorithm sets the promise's state as "resolving".

On Fri, Jun 28, 2013 at 10:53 PM, Anne van Kesteren <[email protected]>wrote:

> On Thu, Jun 27, 2013 at 2:51 AM, Yutaka Hirano <[email protected]>
> wrote:
> > Hi, I am implementing promises and I have a question.
> > In resolve algorithm, we create promise callbacks for the given resolver
> and
> > pass them to a (possibly) user defined function.
> > A user can call them more than once.
> > Since a promise callback for |resolver| and |algorithm| runs |resolver|'s
> > |algorithm| and the |algorithm| doesn't checks |resolver|'s resolved
> flag,
> > it seems that the promise can be resolved or rejected multiple times.
> > Is it correct? I think the check for the resolved flag is needed in:
> >  - promise callback
> >  - 4.4 in resolve algorithm.
>
> What do you mean by 4.4? I think you're right that this is
> problematic, but it's not entirely clear to me this solves it.
>
>
> --
> http://annevankesteren.nl/
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.