Recall & Review
beginner
What is the purpose of the
{#await} block in Svelte?The
{#await} block lets you handle promises directly in your Svelte templates. It shows different content while waiting, when resolved, or if an error occurs.Click to reveal answer
beginner
How do you show a loading message while waiting for a promise in a Svelte
{#await} block?Use the
pending part of the block. The content before :then runs while waiting (pending). For example:<br>{#await promise} Loading... {/await}Click to reveal answer
intermediate
How can you handle errors in a Svelte
{#await} block?Use the
:catch block inside {#await}. It shows content if the promise rejects. Example:<br>{#await promise}<br>Loading...<br>:then data<br>Show data<br>:catch error<br>Show error message<br>{/await}Click to reveal answer
intermediate
What happens if you omit the
:then block in a Svelte {#await} block?If you omit
:then, the block only shows the pending or catch content. You won't see the resolved data because there's no place to display it.Click to reveal answer
beginner
Can you use multiple
{#await} blocks in one Svelte component?Yes, you can use as many
{#await} blocks as you want. Each handles its own promise independently, letting you show loading, success, or error states for each async task.Click to reveal answer
What part of the
{#await} block runs while the promise is still loading?✗ Incorrect
The content before
:then runs while the promise is pending (loading).How do you access the resolved value of a promise inside a
{#await} block?✗ Incorrect
The resolved value is passed as a variable to the
:then block.What does the
:catch block do in a {#await} block?✗ Incorrect
The
:catch block handles errors if the promise fails.Is it possible to omit the
:catch block in a {#await} block?✗ Incorrect
You can omit
:catch, but then errors won’t show any UI feedback.Can you nest
{#await} blocks inside each other in Svelte?✗ Incorrect
You can nest
{#await} blocks to handle multiple async operations step-by-step.Explain how to use the
{#await} block in Svelte to show loading, success, and error states for a promise.Think about the three parts of the block: waiting, success, and failure.
You got /3 concepts.
Describe what happens if you omit the
:then block in a {#await} block and why you might want to include it.Consider how the UI changes when the promise finishes.
You got /3 concepts.