Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Dec 17, 2020

Conversation

arackaf
Copy link
Contributor

@arackaf arackaf commented Dec 11, 2020

Fixes: #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.

…n, which prevented the teardown callback from firing.

Have the load event no longer fire if the Loadable component was unmounted before the loading finished.
@arackaf arackaf changed the title Fix the unloader prop by having onMount no longer be an async functio… Fix the unloader prop, and suppress load event when un-mounted Dec 11, 2020
Loadable.svelte Outdated Show resolved Hide resolved
Loadable.svelte Outdated Show resolved Hide resolved
Loadable.svelte Show resolved Hide resolved
@kaisermann
Copy link
Owner

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

Loadable.svelte Show resolved Hide resolved
Loadable.svelte Show resolved Hide resolved
@kaisermann kaisermann merged commit 50ff154 into kaisermann:master Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

load event fires even if component is unmounted before the load finishes
2 participants