RE: [promises] Guidance on the usage of promises for API developers

From: Boris Zbarsky <bzbarsky@MIT.EDU>

> On 1/14/14 9:22 AM, Domenic Denicola wrote:
>> Do you think it would be improved by nesting step 5 under "These steps will be run asynchronously"?
> Yes.  Otherwise if there is another method that allows synchronously checking whether a bookmark has been added I would expect such a method to return true if called immediately after the addBookmark as specified here returns, whereas the obvious desired behavior is for it to return false.

I think I see what you are saying. I was implicitly assuming that the act of asking the user anything would be asynchronous, whereas it's important to state that. Otherwise, the side effects of adding a bookmark could be allowed to happen synchronously---even if the promise-enforced asynchrony ensures that e.g. `addBookmark.then(onAdded)` only calls `onAdded` asynchronously.

In #whatwg jgraham pointed out:

09:41:58 <jgraham> Domenic_: Note that "will" in spec language is a statement of fact
09:43:35 <jgraham> So if you were to say "these steps will be run asynchronously", there would have to be text elsewhere that actually caused those steps to run

So maybe we need slightly better phrasing; help appreciated.

I do want to clarify that I want to avoid explicitly queuing needless tasks, which then themselves go and perform asynchronous actions. Instead, just perform the asynchronous action, and use the promise microtask queue to the deliver the results. You can see some discussion between Marcos and I on this point at [1].


Received on Tuesday, 14 January 2014 15:44:33 UTC