Consider tearing down the subscription to prevent memory leak.
Since we are in JS land (not svelte), I would expect onDestroy() use is probably inappropriate, so....
Software hacker working in the industry since 2003. Currently loves: #Typescript and #Svelte. Founder of Chimera, the first makerspace in northern California.
Why would you want to unsubscribe from your store in this context?
Also, as far as I'm aware, onbeforeunload event is fired when a window is being destroyed so there would be no need to unsubscribe since the JS runtime is also destroyed for this page, unless I'm not understanding what you're trying to do?
Consider tearing down the subscription to prevent memory leak.
Since we are in JS land (not svelte), I would expect onDestroy() use is probably inappropriate, so....
const unsubscribe = content.subscribe((value) => localStorage.content = value)
window.onbeforeunload = unsubscribe;
Why would you want to unsubscribe from your store in this context?
Also, as far as I'm aware,
onbeforeunload
event is fired when a window is being destroyed so there would be no need to unsubscribe since the JS runtime is also destroyed for this page, unless I'm not understanding what you're trying to do?developer.mozilla.org/en-US/docs/W...