pass object

effect-abort
Dominic Gannaway 1 week ago
parent 085718dc9c
commit df4885e62e

@ -234,7 +234,7 @@ declare namespace $derived {
* https://svelte.dev/docs/svelte/$effect
* @param fn The function to execute
*/
declare function $effect(fn: (signal: AbortSignal) => void | ((signal: AbortSignal) => void)): void;
declare function $effect(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
declare namespace $effect {
/**
@ -253,7 +253,7 @@ declare namespace $effect {
* https://svelte.dev/docs/svelte/$effect#$effect.pre
* @param fn The function to execute
*/
export function pre(fn: (signal: AbortSignal) => void | ((signal: AbortSignal) => void)): void;
export function pre(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
/**
* 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.

@ -403,12 +403,13 @@ export function update_reaction(reaction) {
if ((flags & EFFECT) !== 0 && /** @type {Function} */ (reaction.fn).length > 0) {
var controller = new AbortController();
var inner = /** @type {Function} */ (0, reaction.fn)(controller.signal);
var signal = controller.signal;
var inner = /** @type {Function} */ (0, reaction.fn)({ signal });
result = () => {
controller.abort('effect destroyed');
inner?.();
}
};
} else {
result = /** @type {Function} */ (0, reaction.fn)();
}

@ -2892,7 +2892,7 @@ declare namespace $derived {
* https://svelte.dev/docs/svelte/$effect
* @param fn The function to execute
*/
declare function $effect(fn: (signal: AbortSignal) => void | ((signal: AbortSignal) => void)): void;
declare function $effect(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
declare namespace $effect {
/**
@ -2911,7 +2911,7 @@ declare namespace $effect {
* https://svelte.dev/docs/svelte/$effect#$effect.pre
* @param fn The function to execute
*/
export function pre(fn: (signal: AbortSignal) => void | ((signal: AbortSignal) => void)): void;
export function pre(fn: (input: { signal: AbortSignal }) => void | ((input: { signal: AbortSignal }) => void)): void;
/**
* 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.

Loading…
Cancel
Save