Skip to content

Allow multiple component hooks for a given Component #12647

Description

@cBournhonesque

What problem does this solve or what need does it fill?

It could be useful to have multiple component hooks for a given Component.
A usecase would be to allow libraries to create component-hooks that won't be overriden by the user.

For example, you could imagine bevy_ecs wanting to update change detection ticks via component hooks, while still allowing the user to define their own component hooks.

PROS:

  • increased flexibility
    CONS:
  • performance? we would have to store a Vec of hooks instead of just Option
  • how to guarantee an ordering between the hooks?

What solution would you like?

Letting ComponentHooks store multiple hooks of a given type (on_add, on_remove, etc.) for a component.

What alternative(s) have you considered?

  • Use observers? (not too familiar with them)
  • do not allow multiple hooks

Metadata

Metadata

Labels

A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleX-Needs-SMEThis type of work requires an SME to approve it.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions