Promises in polymer

1,881 views
Skip to first unread message

bkar...@gmail.com

unread,
Oct 17, 2013, 11:29:28 AM10/17/13
to polym...@googlegroups.com
Given all that polymer is doing with normalizing the layers, etc - it feels like polymer should include a prollyfill for Promises.  Would make several parts of the code easier to grok and manage.  In mucking with the patterns in HTML Imports and attempting to shim in something like the parse observers I suggested elsewhere I hit up against how Loader is used and it looks like it is effectively just managing something like promises there... In the existing code you know all link tags up front because you wait until DOMContentLoaded, so that works fine... Shifting this way means that isn't true.  With promises, that would be pretty easy to plug in in the right place I think, but it seems there are callback chains in the pattern right now that make this hard.  

Feels like Promises are an important part of the future platform, let's add it?

Daniel Freedman

unread,
Oct 21, 2013, 3:58:39 PM10/21/13
to bkar...@gmail.com, polymer-dev, Alex Russell
To follow up, we think Promises are an important part of the Web Platform, and we should certainly add a spec conforming polyfill to the Platform layer.

I asked Alex Russell about the status of Promises recently, and he said that there were some inflight API changes and advised to wait for the spec and polyfill implementations to catch up.

I'm inclined to agree on the basis of reducing churn, and hold off on including a Promises implementation in Platform until a good polyfill is ready.


On Thu, Oct 17, 2013 at 8:29 AM, <bkar...@gmail.com> wrote:
Given all that polymer is doing with normalizing the layers, etc - it feels like polymer should include a prollyfill for Promises.  Would make several parts of the code easier to grok and manage.  In mucking with the patterns in HTML Imports and attempting to shim in something like the parse observers I suggested elsewhere I hit up against how Loader is used and it looks like it is effectively just managing something like promises there... In the existing code you know all link tags up front because you wait until DOMContentLoaded, so that works fine... Shifting this way means that isn't true.  With promises, that would be pretty easy to plug in in the right place I think, but it seems there are callback chains in the pattern right now that make this hard.  

Feels like Promises are an important part of the future platform, let's add it?

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Keith Garrod

unread,
Aug 11, 2014, 9:00:47 AM8/11/14
to polym...@googlegroups.com, bkar...@gmail.com, sligh...@google.com
Is there any movement on this? 

Has anybody used a promises library with Polymer?

Eric Bidelman

unread,
Aug 11, 2014, 11:38:09 AM8/11/14
to Keith Garrod, polymer-dev, bkar...@gmail.com, Alex Russell
Hi Keith,

Some of the Google Analytics elements use https://github.com/getify/native-promise-only. The Analytics folks had an existing API they wrapped.  Not sure how exemplar it would be for Polymer, but it does provide examples of how to combine the two.

Hope that helps,
Eric


jamr...@gmail.com

unread,
Aug 30, 2016, 1:49:36 AM8/30/16
to Polymer
It appears to me that promises are a part of the default Polymer polyfills. I do not know this for a fact, but promises seem to be working just fine straight out of the Polymer Starter Kit.

var promise = new Promise(function(resolve, reject)  {
    resolve('Yay, I am a promise');
});
promise.then(function(yay) {
    console.log(yay);
});

My console returned  . . .
    -> Yay, I am a promise
. . . so I am assuming promises work with Polymer. :)

Daniel Llewellyn

unread,
Aug 30, 2016, 2:48:42 AM8/30/16
to jamr...@gmail.com, Polymer
On Tue, 30 Aug 2016 at 06:49 <jamr...@gmail.com> wrote:
It appears to me that promises are a part of the default Polymer polyfills. I do not know this for a fact, but promises seem to be working just fine straight out of the Polymer Starter Kit.

That is incorrect.

Promises are not part of Polymer, nor the WebComponents polyfill. They are already available in all modern browsers (excepting Internet Explorer which I would consider to not be "modern" anyway). There is no need for polyfills as the topic-starter requested unless you need to support IE.

jamr...@gmail.com

unread,
Oct 10, 2016, 7:36:26 PM10/10/16
to Polymer, jamr...@gmail.com
Thank you for that information. What is the best way to implement Promises for ancient browsers that don't support Promises, in the context of Polymer?
Reply all
Reply to author
Forward
0 new messages