Domain events
A domain event is a domain object that defines an event.
Domain events are powerful mechanisms to keep domain models encapsulated. This can be accomplished by allowing various observers from outer layers to register for a domain event (signal).
The problem with domain events in OOP is that the typical implementation is complex and relies on side-effects. Event observations are typically declared in the composition root and thus, it is not immediately obvious from the perspective of the producer which observers will be invoked. In FP, a domain event is simply a value returned by a function in an aggregate. Observers can be explicitly registered as filters.
Furthermore, FRP can handle domain events very effectively. On the other ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access