2

can we use async / await with Polymer 2.0 ?

https://developers.google.com/web/fundamentals/getting-started/primers/async-functions , As soon as I use it in my code it throws errors on hydrolysis / analysis. Any sample code will be helpful too if there is a any special guidance on this.

Regards, S

Sowmyan Soman
  • 853
  • 1
  • 9
  • 21

1 Answers1

0

I am also interested in the subject and from what I can understand now it is not supported out of the box. Async functions are part of ES2017 and are in Draft state now. So if you want to use it you should either use transpiler like Babel or use TypeScript. In either case you need to transpile async/await to ES6 or ES5. Polymer 2.0 is going to suport TypeScript at some point, but it does not support it yet.

Check out the tutorial on how you could integrate BabelJS Build an ES2015/ES6 app with the Polymer Starter Kit

When you have transpiler in place you can use async/await everywhere where promises are supported by Polymer.

Andrii Litvinov
  • 12,402
  • 3
  • 52
  • 59