It's important to avoid memory leaks, and Svelte 3 is no exception. When we're using the subscribe
method from Svelte store in a component, it's important to clean ofter ourselves (especially if we're going to instantiate and destroy this component many times over).
In this lesson we're going to learn how to use unsubscribe
to stop subscribing to the store change in a component's onDestroy
call, as well how to use auto-subscriptions to refer to the store value and let Svelte take care of cleaning after us to avoid memory leaks.