Replies: 3 comments 2 replies
-
|
How about separate your logic into a separate file? |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I don't hate the idea, but I'll play the devil's advocate here.
Overall, not a bad thing, in my untrained eye. Interested to hear other opinions. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Already addressed by this: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Statement
Svelte requires that all reactive state must be declared in the
<script>block at the top of the component. This creates separation between state declarations and their usage in the template, making code harder to read and maintain, especially in large components.Current situation:
You end up constantly scrolling between the script block and template to understand what state controls which part of the UI.
Desired Outcome
Enable scoped (preferably, but not required), localized state declarations within the template itself, keeping state close to where it's actually used.
This would allow developers to:
Possible Implementation (Example)
One approach could be something like
{#let}blocks:But this is just one possible syntax. The core request is for some way to declare reactive state closer to its usage point in the template, preferably with appropriate scoping.
Use Cases
Additional Notes
This isn't about replacing script-level state for shared/component-wide concerns—those should absolutely stay in
<script>. This is about providing an option for truly local UI state that doesn't need to be component-wide.P.S. This is a human-made idea written with AI, and proofread/edited by HI (Human Intelligence).
Beta Was this translation helpful? Give feedback.
All reactions