Skip to content

Is there a way to simplify this code avoiding to call onDestroy manually each time? #10222

Answered by Conduitry
frederikhors asked this question in Q&A
Discussion options

You must be logged in to vote

You can encapsulate the onDestroy in another module, as in https://svelte.dev/tutorial/ondestroy

Unless you are sure your component will only ever be run in a browser, I would also suggest moving the subscription into an onMount.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by frederikhors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants