Skip to content

LifecycleEvent

LifecycleEvent = { id: EntityId; type: "EntityCreated"; } | { id: EntityId; type: "EntityDestroyed"; } | { component: string; id: EntityId; type: "ComponentAdded"; value: unknown; } | { component: string; id: EntityId; type: "ComponentRemoved"; } | { id: EntityId; tag: string; type: "TagAdded"; } | { id: EntityId; tag: string; type: "TagRemoved"; }

Defined in: src/lifecycle.ts:16

Engine-internal lifecycle events emitted by EcsWorld. These are distinct from any game-specific event union — they describe structural changes to the entity/component graph and are consumed by tooling (dev inspector, plugins, network sync, persistence tracking).

set() on an existing id fires ComponentRemoved (via the store’s replace-semantics) followed by ComponentAdded, so consumers can treat the pair as an update.

Each event is built only while its type has a subscriber on world.lifecycle, so a handler sees only changes made after it subscribed.