refactor: change usage of await
This commit is contained in:
parent
b1c2455f88
commit
514217451a
|
@ -11,24 +11,30 @@
|
||||||
|
|
||||||
let connected = false;
|
let connected = false;
|
||||||
|
|
||||||
let types = {};
|
async function getNetworks() {
|
||||||
|
let types = {};
|
||||||
|
|
||||||
const waitConnect = waitForConnected(async () => {
|
return new Promise((resolve) => {
|
||||||
connected = true;
|
waitForConnected(async () => {
|
||||||
|
connected = true;
|
||||||
|
|
||||||
const types = await networkClient.getTypes();
|
const allTypes = await networkClient.getTypes();
|
||||||
|
|
||||||
for (const type of types) {
|
for (const type of allTypes) {
|
||||||
types[type] = await networkClient.getNetworksByType(type);
|
types[type] = await networkClient.getNetworksByType(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
resolve(types);
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<Header />
|
<Header />
|
||||||
<Art />
|
<Art />
|
||||||
<div class="content" class:connected>
|
<div class="content connected">
|
||||||
{#await waitConnect}
|
{#await getNetworks() then types}
|
||||||
<div class="content-grid">
|
<div class="content-grid">
|
||||||
{#each Object.entries(types) as [type, networks]}
|
{#each Object.entries(types) as [type, networks]}
|
||||||
<div>
|
<div>
|
||||||
|
|
Reference in New Issue