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

More flexibility when using {#await} #4473

Closed
alex0ide opened this issue Feb 26, 2020 · 1 comment
Closed

More flexibility when using {#await} #4473

alex0ide opened this issue Feb 26, 2020 · 1 comment

Comments

@alex0ide
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to only catch errors on a promise, and to do so I'm forced to do {#await promise}{:catch error} (my code) {/await}

Describe the solution you'd like
Like the {#await promise then result} short-hand, I would love a {#await promise catch error} short-hand.

How important is this feature to you?
I'm trying to figure out a pattern for my Svelte routes that involves doing something like

const gotGroup = need('group', groupId) // this is a promise
$: group = $groups[groupId]

and then, in different parts of the code, I might want to catch an error, but not show anything while it's loading, and don't get the result either because I'm getting that from the store:

{#await gotGroup}{:catch error}
    {error}
{/await}

Additional context
Svelte compiler throws a warning because of an {#await} block being empty when doing {#await promise}{:catch error}

A question I have, separate from this feature and about the {#await} block, is if it's possible to use inside of class= or any other prop inside an element (class="{#await promise}loading{/await}"). If it's not, what's the alternative? I don't want to repeat code for the two paths.

@antony
Copy link
Member

antony commented Apr 9, 2020

Duplicate of #3623

Please keep issues to a single request please - ignoring additional question

@antony antony closed this as completed Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants