-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Description
When iterating over a list, I would like to be able to perform actions on that list without creating a separate component with its own local variables.
<script>
let promise = 0
let next = (value) =>
new Promise(resolve => setTimeout(() => resolve(value + 1), 1000))
</script>
{#each {length: 5} as i}
{#await promise}
Waiting
{:then result}
<button on:click={() => promise = next(result)}>Next</button>
result: {result}
{:catch error}
error: {error}
{/await}
{/each}
with {#await let promise}
The action is local to each iteration.
and with a default value {#await let promise = "foo"}