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

Warn against constructors in callbacks without accepting scope as an argument #358

Open
dphfox opened this issue Jul 2, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request ready to work on Enhancements/changes ready to be made targeting: FusionKit About official developer tooling

Comments

@dphfox
Copy link
Owner

dphfox commented Jul 2, 2024

In some areas of Fusion such as Computed callbacks, you're expected to place constructed items into a scope provided as an argument.

If the function is not defined with enough parameters, that scope is not accessible in the callback, and thus it's generally an error to construct objects in that callback as they'll pile up in another scope.

It's possible to detect this using the arity information from debug.info. When a 1-parameter callback is passed to a Computed, for example, we know that it will not capture the scope passed as argument 2, and as a result can infer that constructions inside that callback have no way to be cleaned up by the Computed. This is generally undesirable.

If for some reason the developer is explicitly logging to some other scope for later destruction, they can explicitly signal that the non-destruction of objects is intentional by including the scope parameter with an underscore prefix, explicitly showing that it is meant to be unused here.

@dphfox dphfox added enhancement New feature or request not ready - evaluating Currently gauging feedback targeting: FusionKit About official developer tooling labels Jul 2, 2024
@dphfox dphfox added ready to work on Enhancements/changes ready to be made and removed not ready - evaluating Currently gauging feedback labels Aug 31, 2024
@dphfox dphfox self-assigned this Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready to work on Enhancements/changes ready to be made targeting: FusionKit About official developer tooling
Projects
None yet
Development

No branches or pull requests

1 participant