Skip to content

Commit

Permalink
docs: mention {#await} on non-Promise values short-circuiting to th…
Browse files Browse the repository at this point in the history
…e fullfilled branch (#9324)

Fixes #9323
  • Loading branch information
HoldYourWaffle committed Oct 19, 2023
1 parent 9900c85 commit 1ed9182
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions documentation/docs/02-template-syntax/03-logic-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,16 @@ Since Svelte 4 it is possible to iterate over iterables like `Map` or `Set`. Ite
{#await expression catch name}...{/await}
```

Await blocks allow you to branch on the three possible states of a Promise — pending, fulfilled or rejected. In SSR mode, only the pending state will be rendered on the server.
Await blocks allow you to branch on the three possible states of a Promise — pending, fulfilled or rejected.
In SSR mode, only the pending branch will be rendered on the server.
If the provided expression is not a Promise only the fulfilled branch will be rendered, including in SSR mode.

```svelte
{#await promise}
<!-- promise is pending -->
<p>waiting for the promise to resolve...</p>
{:then value}
<!-- promise was fulfilled -->
<!-- promise was fulfilled or not a Promise -->
<p>The value is {value}</p>
{:catch error}
<!-- promise was rejected -->
Expand Down

0 comments on commit 1ed9182

Please sign in to comment.