- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Mon, 2 Sep 2013 12:19:21 -0700
- To: David Bruant <bruant.d@gmail.com>
- Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
On Mon, Sep 2, 2013 at 10:56 AM, David Bruant <bruant.d@gmail.com> wrote:
> Hi,
>
> I apologize in advance if this has been discussed already, I'm a bit behind
> regarding promise discussions.
>
> As far as I know, currently, standard functions that expect an object of a
> given type will throw when passed a promise. However, wouldn't it be elegant
> to do:
>
> var dataP = getData(url1); // http GET
> var templateP = getTemplate(url2); // http GET
> var nodeP = Promise.every(templateP, dataP).then(compileTemplate);
> document.body.appendChild(nodeP);
Why not instead just do:
var dataP = getData(url1); // http GET
var templateP = getTemplate(url2); // http GET
var nodeP = Promise.every(templateP, dataP)
.then(compileTemplate)
.then(node=>document.body.appendChild(node));
?
~TJ
Received on Monday, 2 September 2013 19:20:10 UTC