Closed TheCymaera closed 1 year ago
I see a couple thumbs down, but haven't seen any reasoning why this wouldn't be beneficial. I'm all for more terse syntax for the same functionality.
Is there anything potentially lost by using a labeled statement (that gets compiled to a function) instead of using the lecture funding we have now?
onMount
is different from registering it with onDestroy
- the latter runs on the server)onMount
/onDestroy
, there are build system plugins that can automatically add thoseAFAIK we can not declare types for label statements at least without a hack so it may be weak for types.
And if we support the label statement for that, we definitely need to drop exist onDestroy
function because we should have 1 way to do this. But it is more painful than benefits for users because users need to do migration tasks.
Regarding performance, I think Svelte is compiler, so we can do what we want to do.
Describe the problem
Lifecycle callbacks are currently registered using functions that are imported from the svelte runtime.
Describe the proposed solution
It would be more concise to use labels, similar to reactive statements. It may also more performant since the callbacks are known at compile-time.
Alternatives considered
If the Explicit Resource Management API is accepted, they could be used for cleanup as well.
Importance
nice to have