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

Re-add destroy methods for individual objects #402

Open
dphblox opened this issue Jan 8, 2025 · 0 comments
Open

Re-add destroy methods for individual objects #402

dphblox opened this issue Jan 8, 2025 · 0 comments
Labels
enhancement New feature or request not ready - evaluating Currently gauging feedback

Comments

@dphblox
Copy link

dphblox commented Jan 8, 2025

With the advent of scopes, objects had their destroy methods removed, because invoking them manually would lead to double-destroy errors. Instead, objects now add cleanup tasks to scopes directly, which has proven effective as a memory management strategy.

However, the lack of individual object destruction forces people to engage with Fusion's scope system and adopt it throughout their Fusion app. This is okay for islands of Fusion code, but less great for isolated use cases of Fusion.

So, as a gradual on-ramp to full usage of scopes, and a good compatibility measure to ensure that other memory management libraries can be used, I propose that objects should be able to remove themselves individually from the scope they're in via a destroy method on the object itself. This would not change the requirement to initialise an object with a scope.

This would be implemented by making each object insert a single inner scope, and cleaning up this inner scope when the object's destroy method is called. The object would be destroyed normally if the outer scope is destroyed.

This should also integrate with borrowed resources like Roblox instances, so that they remove themselves when they are individually destroyed.

@dphblox dphblox added enhancement New feature or request not ready - evaluating Currently gauging feedback labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request not ready - evaluating Currently gauging feedback
Projects
None yet
Development

No branches or pull requests

1 participant