Expand description
Entity events report creation, explicitly supplied initial values, and later property changes:
EntityCreatedEventis emitted when an entity has been created.PropertyInitializedEventis emitted for each non-default, non-derived property value explicitly supplied during creation.PropertyChangeEventis emitted when a property is subsequently updated.
Client code can subscribe to these events with the Context::subscribe_to_event<IxaEvent>(handler) method:
ⓘ
// Suppose `InfectionStatus` is a property of the entity `Person`.
// A type alias for property change events makes code more concise and readable.
pub type InfectionStatusEvent = PropertyChangeEvent<Person, InfectionStatus>;
// Suppose we want to execute the following function whenever `InfectionStatus` changes.
fn handle_infection_status_change(context: &mut Context, event: InfectionStatusEvent){
// ... handle the infection status change event ...
}
// We do so by subscribing to this event.
context.subscribe_to_event::<InfectionStatusEvent>(handle_infection_status_change);
// Observe a non-default value explicitly supplied when a person is created.
context.subscribe_to_event(
|_context, event: PropertyInitializedEvent<Person, InfectionStatus>| {
// ... use event.entity_id and event.value ...
},
);A non-derived property sits on the type-erased side of the boundary of its dependent’s PropertyValueStore, so it
needs to somehow trigger the creation of and emit the change events for its dependents in a type-erased way.
Property change events are triggered and collected on the outside of the type-erased PropertyValueStore boundary,
because a non-derived p
Structs§
- Entity
Created Event - Emitted when a new entity is created. These should not be emitted outside this module.
- Property
Change Event - Emitted when a property is updated. These should not be emitted outside this module.
- Property
Initialized Event - Emitted for a non-default, non-derived property value supplied when an entity is created.