Files
Stackq/node_modules/runed/dist/utilities/is-mounted/is-mounted.svelte.js
T
eewing cf73cd3b4c INIT
2026-02-17 14:10:16 -06:00

22 lines
512 B
JavaScript

import { untrack } from "svelte";
/**
* Returns an object with the mounted state of the component
* that invokes this function.
*
* @see {@link https://runed.dev/docs/utilities/is-mounted}
*/
export class IsMounted {
#isMounted = $state(false);
constructor() {
$effect(() => {
untrack(() => (this.#isMounted = true));
return () => {
this.#isMounted = false;
};
});
}
get current() {
return this.#isMounted;
}
}