refactor: change usage of await

This commit is contained in:
Derrick Hammer 2023-07-27 03:00:00 -04:00
parent b1c2455f88
commit 514217451a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 16 additions and 10 deletions

View File

@ -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>