-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed as not planned
Description
Describe the problem
Currently the only way to have a top-level {@const …} to avoid redundant computation …
<script lang="ts">
// ...
</script>
<ul>
<li>{expensiveComputation().foo}</li>
<li>{expensiveComputation().bar}</li>
<li>{expensiveComputation().baz}</li>
</ul>… is to wrap everything in a silly {#if true} … {/if} block:
<script lang="ts">
// ...
</script>
{#if true}
{@const result = expensiveComputation()}
<ul>
<li>{result.foo}</li>
<li>{result.bar}</li>
<li>{result.baz}</li>
</ul>
{/if}Describe the proposed solution
Given that the above silly hack works I see no reason why there shouldn't be first-class support for it:
<script lang="ts">
// ...
</script>
{@const result = expensiveComputation()}
<ul>
<li>{result.foo}</li>
<li>{result.bar}</li>
<li>{result.baz}</li>
</ul>Importance
would make my life easier
Metadata
Metadata
Assignees
Labels
No labels