diff --git a/packages/runed/src/lib/utilities/PersistedState/PersistedState.svelte.ts b/packages/runed/src/lib/utilities/PersistedState/PersistedState.svelte.ts index 1f918d77..f2d60032 100644 --- a/packages/runed/src/lib/utilities/PersistedState/PersistedState.svelte.ts +++ b/packages/runed/src/lib/utilities/PersistedState/PersistedState.svelte.ts @@ -134,13 +134,13 @@ export class PersistedState { $effect(() => { if (!syncTabs || storageType !== "local") return; - return addEventListener(window, "storage", this.#handleStorageEvent.bind(this)); + return addEventListener(window, "storage", this.#handleStorageEvent); }); }); }); } - #handleStorageEvent(event: StorageEvent): void { + #handleStorageEvent = (event: StorageEvent): void => { if (event.key !== this.#key || !this.#storage) return; const valueFromStorage = getValueFromStorage({ @@ -152,7 +152,7 @@ export class PersistedState { if (valueFromStorage.found) { this.#current = valueFromStorage.value; } - } + }; get current(): T { this.#subscribe();