Skip to content

Commit 0853017

Browse files
committed
types + changeset
1 parent df4885e commit 0853017

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

.changeset/popular-walls-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': minor
3+
---
4+
5+
feat: pass AbortSignal to effects and allow async signature

packages/svelte/src/ambient.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ declare namespace $derived {
234234
* https://svelte.dev/docs/svelte/$effect
235235
* @param fn The function to execute
236236
*/
237-
declare function $effect(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
237+
declare function $effect(
238+
fn: (input: { signal: AbortSignal }) => void | (() => void) | Promise<void>
239+
): void;
238240

239241
declare namespace $effect {
240242
/**
@@ -253,7 +255,9 @@ declare namespace $effect {
253255
* https://svelte.dev/docs/svelte/$effect#$effect.pre
254256
* @param fn The function to execute
255257
*/
256-
export function pre(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
258+
export function pre(
259+
fn: (input: { signal: AbortSignal }) => void | (() => void) | Promise<void>
260+
): void;
257261

258262
/**
259263
* The `$effect.tracking` rune is an advanced feature that tells you whether or not the code is running inside a tracking context, such as an effect or inside your template.

packages/svelte/types/index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,9 @@ declare namespace $derived {
28922892
* https://svelte.dev/docs/svelte/$effect
28932893
* @param fn The function to execute
28942894
*/
2895-
declare function $effect(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
2895+
declare function $effect(
2896+
fn: (input: { signal: AbortSignal }) => void | (() => void) | Promise<void>
2897+
): void;
28962898

28972899
declare namespace $effect {
28982900
/**
@@ -2911,7 +2913,9 @@ declare namespace $effect {
29112913
* https://svelte.dev/docs/svelte/$effect#$effect.pre
29122914
* @param fn The function to execute
29132915
*/
2914-
export function pre(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
2916+
export function pre(
2917+
fn: (input: { signal: AbortSignal }) => void | (() => void) | Promise<void>
2918+
): void;
29152919

29162920
/**
29172921
* The `$effect.tracking` rune is an advanced feature that tells you whether or not the code is running inside a tracking context, such as an effect or inside your template.

0 commit comments

Comments
 (0)