Warn against constructors in callbacks without accepting scope
as an argument
#358
Labels
enhancement
New feature or request
ready to work on
Enhancements/changes ready to be made
targeting: FusionKit
About official developer tooling
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 thescope
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.
The text was updated successfully, but these errors were encountered: