# Objective I set out with one simple goal: clearly document the differences between each of the component lifecycle events via module docs. Unfortunately, no such module existed: the various lifecycle code was scattered to the wind. Without a unified module, it's very hard to discover the related types, and there's nowhere good to put my shiny new documentation. ## Solution 1. Unify the assorted types into a single `bevy_ecs::component_lifecycle` module. 2. Write docs. 3. Write a migration guide. ## Testing Thanks CI! ## Follow-up 1. The lifecycle event names are pretty confusing, especially `OnReplace`. We should consider renaming those. No bikeshedding in my PR though! 2. Observers need real module docs too :( 3. Any additional functional changes should be done elsewhere; this is a simple docs and re-org PR. --------- Co-authored-by: theotherphil <phil.j.ellison@gmail.com>
1.0 KiB
| title | pull_requests | |
|---|---|---|
| Component lifecycle reorganization |
|
To improve documentation, discoverability and internal organization, we've gathered all of the component lifecycle-related code we could and moved it into a dedicated lifecycle module.
The lifecycle / observer types (OnAdd, OnInsert, OnRemove, OnReplace, OnDespawn) have been moved from the bevy_ecs::world to bevy_ecs::lifecycle.
The same move has been done for the more internal (but public) ComponentId constants: ON_ADD, ON_INSERT, ON_REMOVE, ON_REPLACE, ON_DESPAWN.
The code for hooks (HookContext, ComponentHook, ComponentHooks) has been extracted from the very long bevy_ecs::components module, and now lives in the bevy_ecs::lifecycle module.
The RemovedComponents SystemParam, along with the public RemovedIter, RemovedIterWithId and RemovedComponentEvents have also been moved into this module as they serve a similar role. All references to bevy_ecs::removal_detection can be replaced with bevy_ecs::lifecycle.