Recall & Review
beginner
What is a promise in JavaScript?
A promise is an object that represents the eventual completion or failure of an asynchronous operation and its resulting value.
Click to reveal answer
intermediate
How does streaming with promises improve user experience in Svelte?
Streaming with promises allows parts of the UI to render as soon as data is available, making the app feel faster and more responsive.
Click to reveal answer
beginner
In Svelte, how can you use a promise to show loading and then display data?
Use the
{#await promise} block to show a loading state, then display the resolved data inside the then section of the {#await} block.Click to reveal answer
intermediate
What happens if a promise rejects inside a Svelte
{#await} block?You can handle errors by adding a
catch block inside {#await} to show an error message or fallback UI.Click to reveal answer
beginner
Why is streaming with promises better than waiting for all data before rendering?
Streaming lets the app show parts of the UI immediately as data arrives, reducing wait time and improving perceived speed.
Click to reveal answer
In Svelte, which block is used to handle promises for streaming data?
✗ Incorrect
The {#await} block is designed to handle promises, showing loading, then resolved data or errors.
What does the 'then' section inside a Svelte {#await} block do?
✗ Incorrect
The 'then' section runs when the promise resolves successfully and displays the data.
How can you show an error message if a promise fails in Svelte?
✗ Incorrect
The catch block inside {#await} handles rejected promises and shows error UI.
Why is streaming with promises useful in web apps?
✗ Incorrect
Streaming lets the app render parts immediately, improving user experience.
Which of these is NOT a benefit of streaming with promises?
✗ Incorrect
Streaming improves perceived speed but cannot make data arrive instantly.
Explain how you would use Svelte's {#await} block to stream data from a promise, including loading and error states.
Think about the three parts: loading, success, and error.
You got /4 concepts.
Describe why streaming with promises can make a web app feel faster and more responsive.
Compare waiting for all data vs showing partial data early.
You got /4 concepts.