Description
Component
's init_component_hooks
method is intimidating and a bit frustrating to use. The obvious solution is to simply make each type of component hook its own method.
As @James-o-brien points out, the most naive solution won't work, because we want to cache whether or not each component has each kind of hook (stored in the flags on archetypes). As far as we know, there's no way to statically check if the function provided is actually a no-op.
This came up in the context of relationships.
This feels like a weird place for this method. I'd kinda prefer making
on_insert
etc methods forComponent
(and removing the awkwardregister_component_hooks
API), and then generating those methods in theComponent
trait with theRelationship
derive macro.
Originally posted by @alice-i-cecile in #17398 (comment)