Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 987 Bytes

aggregate2.rst

File metadata and controls

36 lines (21 loc) · 987 Bytes

Aggregate 2 - Explicit event classes

This example shows a slightly different version of the Dog class used in the tutorial and module docs.

It uses the Aggregate class and the @event decorator from the library, but explicitly defines event classes to match command method signatures. As in the previous example, the event are triggered when the command methods are called, and the bodies of the command methods are used to apply the events to the aggregate state.

As in the previous example, the application code simply uses the aggregate class as if it were a normal Python object class.

Domain model

../../../eventsourcing/examples/aggregate2/domainmodel.py

Application

../../../eventsourcing/examples/aggregate2/application.py

Test case

../../../eventsourcing/examples/aggregate2/test_application.py