Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Being able to omit the variable name when doing {#await promise then value} {/await} #6476

Closed
aradalvand opened this issue Jun 29, 2021 · 1 comment

Comments

@aradalvand
Copy link

aradalvand commented Jun 29, 2021

Describe the problem

Suppose you have a promise that doesn't return anything (i.e. Promise<void> in TypeScript terms). If you want to use Svelte's await syntax for such a promise, you can do so with separate {#await} {:then} blocks, and you're perfectly allowed to omit the variable name in the {:then} block, like so:

{#await someVoidPromise}
  Waiting...
{:then}
  Done.
{/await}

Svelte also provides an alternative syntax for when you don't want to show anything until the promise is resolved. It looks like this:

{#await somePromise then value}
    Done: {value}
{/await}

Explained in the official tutorial here.

Unlike what I expected, you cannot use the above syntax with a void promise, in other words you can't omit the variable name, so you can't do:

{#await someVoidPromise then}
    Done.
{/await}

You'd get the following error:

image

Describe the proposed solution

I think the aforementioned syntax should be supported. You should be able to omit the variable name after then when you don't have a separate {#await} block, just like you can do so when you do have a separate {#await} block.

Alternatives considered

You'd have to do the following, and have an empty {#await} block:

{#await someVoidPromise}
{:then}
  Done.
{/await}

which isn't nice.

Importance

would make my life easier

@Conduitry
Copy link
Member

Duplicate of #6270.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants