mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-17 11:29:58 +08:00
Optimize unnecessary uses of new Promise() (#4442)
* Optimize out unnecessary uses of new Promise() * tweak --------- Co-authored-by: pngwn <hello@pngwn.io>
This commit is contained in:
parent
ff6e676a92
commit
9c5a1d871c
@ -10,8 +10,7 @@ No changes to highlight.
|
||||
|
||||
## Other Changes:
|
||||
|
||||
No changes to highlight.
|
||||
|
||||
- Clean up unnecessary `new Promise()`s by [@akx](https://github.com/akx) in [PR 4442](https://github.com/gradio-app/gradio/pull/4442).
|
||||
## Breaking Changes:
|
||||
|
||||
No changes to highlight.
|
||||
|
@ -135,25 +135,23 @@
|
||||
document?: (arg0: Record<string, unknown>) => Documentation;
|
||||
};
|
||||
|
||||
function load_component<T extends ComponentMeta["type"]>(
|
||||
async function load_component<T extends ComponentMeta["type"]>(
|
||||
name: T
|
||||
): Promise<{
|
||||
name: T;
|
||||
component: LoadedComponent;
|
||||
}> {
|
||||
return new Promise(async (res, rej) => {
|
||||
try {
|
||||
const c = await component_map[name]();
|
||||
res({
|
||||
name,
|
||||
component: c as LoadedComponent
|
||||
});
|
||||
} catch (e) {
|
||||
console.error("failed to load: " + name);
|
||||
console.error(e);
|
||||
rej(e);
|
||||
}
|
||||
});
|
||||
try {
|
||||
const c = await component_map[name]();
|
||||
return {
|
||||
name,
|
||||
component: c as LoadedComponent
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(`failed to load: ${name}`);
|
||||
console.error(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
const component_set = new Set<
|
||||
|
@ -9,18 +9,11 @@
|
||||
|
||||
let dismounted: boolean;
|
||||
|
||||
function animate(): Promise<void> {
|
||||
return new Promise(async (res) => {
|
||||
await Promise.all([top.set([125, 140]), bottom.set([-125, -140])]);
|
||||
|
||||
await Promise.all([top.set([-125, 140]), bottom.set([125, -140])]);
|
||||
|
||||
await Promise.all([top.set([-125, 0]), bottom.set([125, -0])]);
|
||||
|
||||
await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
|
||||
|
||||
res();
|
||||
});
|
||||
async function animate() {
|
||||
await Promise.all([top.set([125, 140]), bottom.set([-125, -140])]);
|
||||
await Promise.all([top.set([-125, 140]), bottom.set([125, -140])]);
|
||||
await Promise.all([top.set([-125, 0]), bottom.set([125, -0])]);
|
||||
await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
|
||||
}
|
||||
|
||||
async function run() {
|
||||
|
Loading…
Reference in New Issue
Block a user