Open abdel-17 opened 3 months ago
Alternative suggestion: Don't rely on $effect.root
. If you want to use a builder outside of Svelte components, you can wrap it with $effect.root
manually. Maybe we can provide it as a separate helper.
let tooltip: Tooltip;
$effect.root(() => {
tooltip = new Tooltip();
});
Currently, we auto cleanup effects by calling
onDestroy
in atry { ... }
block with an emptycatch {}
to avoid errors when a melt component is created outside of a .svelte file. This is error-prone, however.An admittedly hacky, but less error-prone alternative, is to first check if we can safely call
onDestroy
by calling an$effect
with a noop.