15 Nov 2023
Intermediate
An event is something that has already happened. A domain event is a specific type of event that occurs within a particular domain. When a domain event occurs, other parts of the same domain are notified so that they can take appropriate action.
Domain events in Domain-Driven Design (DDD) are records of things that have already happened in the domain. They are used to notify the state changes that have happened in the domain.
For example, if an order is placed in an online store, this would be considered a domain event. The other parts of the store, such as the inventory system and the shipping system, would be notified of this event so that they could update their records accordingly.
Here are some examples of domain events:
- In an e-commerce system, a "OrderPlaced" event might be published when a customer places an order.
- In a banking system, an "AccountCreated" event might be published when a new account is created.
- In a social media system, a "PostCreated" event might be published when a new post is created.
domain-driven-design-ddd
domain-events