You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/await-then-destruct-default/main.svelte

34 lines
630 B

<script>
let object = Promise.resolve({ b: 2, c: 3 });
let array = Promise.resolve([1, 2]);
let objectReject = Promise.reject({ b: 2, c: 3 });
let arrayReject = Promise.reject([1, 2]);
</script>
{#await object then { a = 3, b = 4, c }}
<p>a: {a}</p>
<p>b: {b}</p>
<p>c: {c}</p>
{/await}
{#await array then [a, b, c = 3]}
<p>a: {a}</p>
<p>b: {b}</p>
<p>c: {c}</p>
{/await}
{#await objectReject then value}
resolved
{:catch { a = 3, b = 4, c }}
<p>a: {a}</p>
<p>b: {b}</p>
<p>c: {c}</p>
{/await}
{#await arrayReject then value}
resolved
{:catch [a, b, c = 3]}
<p>a: {a}</p>
<p>b: {b}</p>
<p>c: {c}</p>
{/await}