-
-
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
{@debug foo} #1635
Comments
What if it was also a directive where you can do : <label>
enter your name
<input bind:value=name>
</label>
<h1 debug:name>Hello {name}!</h1> This would allow you to specify the debug in reference to a particular element. This would allow for someone to do |
Discussion from discord found that the directive approach wasn't necessary. Compiled code would go in the same place either way. |
I'd like a way to do "debug all changes" which would mean the debugger is triggered on block creation and on every update. This is very doable via In order to prevent a large number of unnecessary It would be used like this:
Benefits would be like the example in react where you want to call debugger "every rerender" which in the case of Svelte is much different but could be replicated in the form of "update me everytime I create or update". First problem, doing a One solution is to have the "debug all" be something like The other solution is to have a regex check I prefer solution 2 because it means we can use |
This was released in 2.10 so can be closed now — thanks @GarrettGeorge! |
FWIW in regard to enabling the behavior of @debug...
|
Whenever @arackaf wants to talk about the perceived superiority of the React programming model, he asks if your template language can use
debugger
statements to pause rendering:And the answer in Svelte's case is 'well, no... because you're not writing code that executes top-to-bottom — it's a different mental model'. The absence of a
render()
function is a feature, and one of the reasons Svelte is so much faster and more memory-efficient.Of course, you can trigger the debugger when particular values change easily enough. Here's one approach:
Using this approach you can also see that Svelte efficiently avoids updating parts of a component that are unchanged.
Including the helper is a slight nuisance though, if you want to just quickly track something down. What if we introduced a
{@debug ...}
tag? The above example would become this:It could take multiple arguments (
{@debug foo, bar, baz}
), and it would probably only get emitted whendev: true
. The compiler could turn it into this:Thoughts?
The text was updated successfully, but these errors were encountered: