You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I personally recommend 2, because for someone like me who comes from other programming languages, I learned a lot from the onDestroy exercise.
Indeed, the onDestroy exercises were complex, but I think it can be made simpler.
I have created two different PRs (as Draft just to avoid both being merged).
Please merge the one that is more suitable.
The text was updated successfully, but these errors were encountered:
I removed the onDestroy exercise after a conversation with the maintainers yesterday — at root, the reason the exercise was so convoluted was that there really aren't many valid use cases for onDestroy. #316 is simpler, but it's still something that doesn't really make sense to do in a real app.
What I've seen in the wild is that people will do this sort of thing:
That's not just unnecessarily verbose, it's buggy — in SSR mode, thing will be undefined, because onDestroy is called at SSR time but onMount isn't. In 99% of cases, the setup work should happen in onMount and the cleanup work should happen in the returned callback.
The manual store subscription case is perhaps the one case where it makes sense, but that's really just a limitation of the store API — the fact that you have to subscribe in order to get the value. We're investigating ways to change that in a future version of Svelte, so that we could potentially get rid of onDestroy altogether, but in the meantime we concluded that removing it from the tutorial — as a precursor to deprecating it — is the best solution.
Uh oh!
There was an error while loading. Please reload this page.
When I run
pnpm build
I get the following error:There are two ways to fix it.
onDestroy
exercise, and make it simpler (chore: simplify the onDestroy exercise #316)I personally recommend 2, because for someone like me who comes from other programming languages, I learned a lot from the
onDestroy
exercise.Indeed, the
onDestroy
exercises were complex, but I think it can be made simpler.I have created two different PRs (as Draft just to avoid both being merged).
Please merge the one that is more suitable.
The text was updated successfully, but these errors were encountered: