W3C home > Mailing lists > Public > www-tag@w3.org > January 2014

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

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Tue, 14 Jan 2014 15:44:01 +0000
To: Boris Zbarsky <bzbarsky@MIT.EDU>, Takeshi Yoshino <tyoshino@google.com>, "www-tag@w3.org" <www-tag@w3.org>
CC: public-webapps <public-webapps@w3.org>
Message-ID: <71d23f757b5645f0a300496c34dafe76@BN1PR05MB325.namprd05.prod.outlook.com>
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].

[1]: https://github.com/domenic/promises-unwrapping/issues/85
Received on Tuesday, 14 January 2014 15:44:34 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:33:23 UTC