kaisermann / svelte-loadable

Dynamically load a svelte component
MIT License
320 stars 13 forks source link

load event fires even if component is unmounted before the load finishes #39

Closed arackaf closed 3 years ago

arackaf commented 3 years ago

If you conditionally render a instance, and then unMount it before the loading finishes, the now-unmounted instance will still fire the load event.

I'm not sure if it's correct that Svelte even acknowledge events from an unmounted component, but regardless it seems like this component should track when it's been removed, and suppress the event.

Also, the onMount function being async prevents the teardown callback from ever firing, which prevents the unloader behavior from working.

PR incoming...