Event-Driven

Domain Events

Description

A Domain Event captures the memory of something interesting which affects the domain. It is strictly part of the domain model.

Where to use

  • DDD (Domain-Driven Design).
  • \n
  • Decoupling side effects.

Real World Example

When a user changes their address, a 'UserAddressChanged' event is created, not just a database update. This allows other systems to react.

Code Example

class DomainEvents:\n    def __init__(self):\n        pass\n\n    def execute(self):\n        print('Executing Domain Events')