mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 12:12:59 -05:00
Fix misused promises (#723)
* Remove an unnecessary await * Add an async IIFE wrapper
This commit is contained in:
@@ -194,11 +194,11 @@ export class BaseEvalElement extends HTMLElement {
|
|||||||
}
|
}
|
||||||
} // end eval
|
} // end eval
|
||||||
|
|
||||||
runAfterRuntimeInitialized(callback: () => Promise<void>){
|
runAfterRuntimeInitialized(callback: () => Promise<void>) {
|
||||||
runtimeLoaded.subscribe(value => {
|
runtimeLoaded.subscribe(value => {
|
||||||
if ('run' in value) {
|
if ('run' in value) {
|
||||||
setTimeout(async () => {
|
setTimeout(() => {
|
||||||
await callback();
|
void callback();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -231,23 +231,27 @@ function createWidget(name: string, code: string, klass: string) {
|
|||||||
// ideally we can just wait for it to load and then run. To do
|
// 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
|
// so we need to replace using the promise and actually using
|
||||||
// the interpreter after it loads completely
|
// the interpreter after it loads completely
|
||||||
// setTimeout(async () => {
|
// setTimeout(() => {
|
||||||
|
// void (async () => {
|
||||||
// await this.eval(this.code);
|
// await this.eval(this.code);
|
||||||
// this.proxy = this.proxyClass(this);
|
// this.proxy = this.proxyClass(this);
|
||||||
// console.log('proxy', this.proxy);
|
// console.log('proxy', this.proxy);
|
||||||
// this.proxy.connect();
|
// this.proxy.connect();
|
||||||
// this.registerWidget();
|
// this.registerWidget();
|
||||||
|
// })();
|
||||||
// }, 2000);
|
// }, 2000);
|
||||||
runtimeLoaded.subscribe(value => {
|
runtimeLoaded.subscribe(value => {
|
||||||
console.log('RUNTIME READY', value);
|
console.log('RUNTIME READY', value);
|
||||||
if ('run' in value) {
|
if ('run' in value) {
|
||||||
runtime = value;
|
runtime = value;
|
||||||
setTimeout(async () => {
|
setTimeout(() => {
|
||||||
|
void (async () => {
|
||||||
await this.eval(this.code);
|
await this.eval(this.code);
|
||||||
this.proxy = this.proxyClass(this);
|
this.proxy = this.proxyClass(this);
|
||||||
console.log('proxy', this.proxy);
|
console.log('proxy', this.proxy);
|
||||||
this.proxy.connect();
|
this.proxy.connect();
|
||||||
this.registerWidget();
|
this.registerWidget();
|
||||||
|
})();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user