From 019b7d145a02747dec75af9b4b98b3661a810b6d Mon Sep 17 00:00:00 2001 From: Fabio Pliger Date: Wed, 20 Apr 2022 18:16:26 -0500 Subject: [PATCH] add timer to register generic widgets --- pyscriptjs/src/components/base.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pyscriptjs/src/components/base.ts b/pyscriptjs/src/components/base.ts index 8f5f566..454e81f 100644 --- a/pyscriptjs/src/components/base.ts +++ b/pyscriptjs/src/components/base.ts @@ -192,14 +192,18 @@ export class BaseEvalElement extends HTMLElement { } connectedCallback() { - console.log(this.name, 'OOOOOOO connected!!!!') - this.eval(this.code).then(() => { - this.proxy = this.proxyClass(this); - console.log('proxy', this.proxy); - this.proxy.connect(); - this.registerWidget(); - }); - console.log(this.name, 'DOOOOONE connected!!!!') + // TODO: we are calling with a 2secs delay to allow pyodide to load + // ideally we can just wait for it to load and then run. To do + // so we need to replace using the promise and actually using + // the interpreter after it loads completely + setTimeout(() => { + this.eval(this.code).then(() => { + this.proxy = this.proxyClass(this); + console.log('proxy', this.proxy); + this.proxy.connect(); + this.registerWidget(); + }); + }, 2000); } async registerWidget(){