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

✨ Allows returning a function from init to run after unmount #3668

Closed
wants to merge 2 commits into from

Conversation

ekwoka
Copy link
Contributor

@ekwoka ekwoka commented Jul 20, 2023

This PR enables the common behavior in component based UI systems, where an onmount function can return a function that will then be called at cleanup.

This would be an alternative to destroy, especially for cleaning up any effect made in init but with the benefit of not needing to manage storing data outside of the closure.

This also handles async init methods that would return a promise that resolves to the cleanup

@calebporzio
Copy link
Collaborator

This makes sense and I appreciate the contribution, however as it is a fairly impactful change I'm going to hold off. Thanks again

@ekwoka
Copy link
Contributor Author

ekwoka commented Jul 24, 2023

I know you mentioned possibly adding it in the past, but wasn't sure if it was backburnered or you decided against it.

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.

2 participants