Closed moaali closed 1 year ago
@moaali Hey!
No bug here: you destructure the values once and instantly unsubscribe. If you want reactivity, you should pick a different syntax. The following will work:
<script>
import {posts} from './stores/posts'
$: ({loading, data} = $posts);
</script>
<div>
{#if loading}
loading...
{:else if data}
{data.title}
{:else}
error
{/if}
</div>
In any case, I recommend getting a fresh look at Svelte's $:
statement.
When using with Svelte I noticed that the query gets stuck at loading state even after the promise fulfils.
Reproduction: https://stackblitz.com/edit/svelte-spaceymen-3i3kjn