-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feature request: {#await promise then}
#6270
Comments
A thought on the semantics of this, I think |
I'm pretty sure we need the |
I don't think that's the case, the compiler could check for the absence of |
I think this covers all the cases? https://svelte.dev/docs#await |
Aside from being overly magical (in my opinion) that isn't sufficient, because then you couldn't show something during loading unless you also wanted to show something after the promise was resolved. Svelte shouldn't impose peculiar restrictions like that. |
Yes, this is not handling any new cases per se. It's just allowing a simpler syntax for an existing case. |
I'm not sure what you mean. Maybe we are misunderstanding each other? I only mean that we can omit the
That's not what I was referring to, I just mean from a compiler POV it isn't hard to figure out which is which either way. |
There are three promise states: pending, resolved, and rejected.
will match the pending state. With your proposal, there is no clean way to have an
So, while your idea does away with the superfluous syntax I'm talking about ( |
Gotcha. I didn't realize that |
+1 The syntax is straightforward and not problematic, and there would be no breaking change or anything either. So, I'm for this. |
This syntax is supported now in 3.41.0. |
Is your feature request related to a problem? Please describe.
If you have a promise whose resolve value you don't care about, you can currently do:
but with the shorthand you can't do:
When you don't need to show a loading state, there is no way to omit the variable for the promise's resolve value. This is a fairly common situation, and it would be good to handle it.
Describe the solution you'd like
Support the above syntax where the variable is omitted.
Describe alternatives you've considered
You can work around this by including a variable that you don't use:
But this is awkward style and may also cause issues with linters.
How important is this feature to you?
Moderate. It's not a show-stopper because there's a workaround, but it also seems like something Svelte should support, and it shouldn't be very difficult.
The text was updated successfully, but these errors were encountered: