File size: 295 Bytes
25c63d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
	}
};