Use async/await instead of promise chaining (#266)

* Use async/await instead of promise chaining

* Await asynchronous operations
This commit is contained in:
woxtu
2022-05-10 02:32:01 +09:00
committed by GitHub
parent d645722421
commit a993d61885
4 changed files with 26 additions and 34 deletions

View File

@@ -61,12 +61,10 @@ export class PyButton extends BaseEvalElement {
// now that we appended and the element is attached, lets connect with the event handlers
// defined for this widget
setTimeout(() => {
this.eval(this.code).then(() => {
this.eval(registrationCode).then(() => {
console.log('registered handlers');
});
});
setTimeout(async () => {
await this.eval(this.code);
await this.eval(registrationCode);
console.log('registered handlers');
}, 4000);
console.log('py-button connected');