In Svelte, we have a very nice and beautiful way to load some data in time and render it using @const:
<script> let a = false;</script><button on:click={() => a = !a}></button>{#if a} {@const table = axios.get(...)} {#await table}<Spinner /> {:then table} ... {/await} {/if}
This way, we don't really have to declare anything in the body. But sometimes we might need to have some logic inside:
{@const table = axios.get(...)}{#await table}<Spinner />{:then table} {#each table as x}<button on:click={() => x.open = true}> Open row!</button> {#if x.open === true} ... {/if} {/each}{/await}
And it will not work, since table is a @const. I want to find a clever and simple way to work this out. Is there any good practice I can use here instead of @const to not overload body of component with state variables?