partey_workadventure/front/src/Components/Lazy.svelte
2022-03-08 11:56:34 +01:00

22 lines
350 B
Svelte

<!-- https://lihautan.com/notes/svelte-lazy-load/ -->
<script>
export let when = false;
export let component;
let loading;
$: if (when) {
load();
}
function load() {
loading = component();
}
</script>
{#if when}
{#await loading then { default: Component }}
<Component />
{/await}
{/if}