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

Compiler warns of "Empty block" if {#await} has no immediate contents or {:catch} is not present #1987

Closed
c0bra opened this issue Jan 16, 2019 · 3 comments

Comments

@c0bra
Copy link
Contributor

c0bra commented Jan 16, 2019

Example REPL (v3)

These two scenarios both result in an "Empty block" warning in the console:

  1. Nothing immediately following {#await ...}
{#await promise}
{:then users}
	{#each users.data as user}
		<div>{user.first_name}</div>
	{/each}
{:catch error}
	<p>Error</p>
{/await}
  1. {:catch ...} not present or empty:
{#await promise}
    <p>Loading...</p>
{:then users}
	{#each users.data as user}
		<div>{user.first_name}</div>
	{/each}
{/await}
@c0bra c0bra changed the title Compiler warns of 'empty block' if {#await} has no immediate contents or {:catch} is not present Compiler warns of "Empty block" if {#await} has no immediate contents or {:catch} is not present Jan 16, 2019
@burningTyger
Copy link
Contributor

burningTyger commented Jan 16, 2019

The docs should also mention the possibility to just write {#await promise then users} since I'm not very fond of the empty block either (renders too fast in most cases anyway).

Edit: Is there a reason it is then othern than the promise chain? Sounds a bit strange to me. Could use as as well as in {#each promise as user} => {#await primise as user}

@Conduitry
Copy link
Member

Looks like there already was an issue for the warning, #1716.

Agree that this short form should be documented though. (I actually wasn't aware it existed.) It's probably easiest to just document it as part of v3, even though it's existed for a while in v2.

@c0bra
Copy link
Contributor Author

c0bra commented Jan 16, 2019

@Conduitry ah yes, I didn't realize there was already an issue filed.

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