kaisermann / svelte-loadable

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

Fix the unloader prop, and suppress load event when un-mounted #40

Closed arackaf closed 3 years ago

arackaf commented 3 years ago

Fixes: https://github.com/kaisermann/svelte-loadable/issues/39

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.

kaisermann commented 3 years ago

Hey @arackaf 👋 Thanks for your effort in resolving this issue 😁 . Just pointed out some issues.