Lifecycle Methods

Lifecycle methods allow executing code at specific points.

Snippet:

<script>\nimport { onMount } from "svelte";\nonMount(() => {\n  console.log("Component mounted");\n});\n</script>

Example:

<script>\nimport { onDestroy } from "svelte";\nonDestroy(() => {\n  console.log("Component destroyed");\n});\n</script>