inference-playground / src /lib /utils /lifecycle.ts
Nymbo's picture
Sync with upstream huggingface-projects/inference-playground (node 22, current Svelte app)
4e2820e verified
Raw History Blame Contribute Delete
295 Bytes
import { onDestroy, onMount } from "svelte";
export const safeOnMount = (fn: (...args: unknown[]) => unknown) => {
try {
onMount(fn);
} catch {
return fn;
}
};
export const safeOnDestroy = (fn: (...args: unknown[]) => unknown) => {
try {
onDestroy(fn);
} catch {
return fn;
}
};