INIT
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user