File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' svelte ' : patch
3+ ---
4+
5+ feat: add type of ` $effect.active `
Original file line number Diff line number Diff line change @@ -68,6 +68,28 @@ declare namespace $effect {
6868 * @param fn The function to execute
6969 */
7070 export function pre ( fn : ( ) => void | ( ( ) => void ) ) : void ;
71+
72+ /**
73+ * The `$effect.active` rune is an advanced feature that tells you whether or not the code is running inside an effect or inside your template.
74+ *
75+ * Example:
76+ * ```svelte
77+ * <script>
78+ * console.log('in component setup:', $effect.active()); // false
79+ *
80+ * $effect(() => {
81+ * console.log('in effect:', $effect.active()); // true
82+ * });
83+ * </script>
84+ *
85+ * <p>in template: {$effect.active()}</p> <!-- true -->
86+ * ```
87+ *
88+ * This allows you to (for example) add things like subscriptions without causing memory leaks, by putting them in child effects.
89+ *
90+ * https://svelte-5-preview.vercel.app/docs/runes#$effect-active
91+ */
92+ export function active ( ) : boolean ;
7193}
7294
7395/**
You can’t perform that action at this time.
0 commit comments