Skip to content

What is the purpose of maintaining a Domain Event array? #116

Answered by Sairyss
Kevinizevbigie asked this question in Q&A
Discussion options

You must be logged in to vote

When a user is created, you may want other parts of the system to know about it, that's why we are emitting Domain Events.
It is an array because there may be multiple events emitted, for example if you execute multiple methods, each one may add an event. Or if one method emits multiple events, for instance when created user is an admin you may also want to emit a second event like AdminCreatedDomainEvent, to prevent your event listeners that are interested only in admins to subscribe for every UserCreatedDomainEvent you can listen to the admin events only.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Kevinizevbigie
Comment options

@Sairyss
Comment options

@Kevinizevbigie
Comment options

@Sairyss
Comment options

Answer selected by Sairyss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants