DomainEvent (reactive_commons v0.7.1) View Source
Events represent a fact inside the domain, it is the representation of a decision or a state change that a system want to notify to its subscribers. Events represents facts that nobody can change, so events are not intentions or requests of anything, An example may be and UserRegistered or a NotificationSent.
Events are the most important topic in a Publish-Subscribe system, because this element let’s notify a many stakeholders in a specific event. An other benefit is the system is decouple, because you can add more subscriber to the system without modify some component.
Link to this section Summary
Functions
Creates a new DomainEvent structure with a generated event_id
Creates a new DomainEvent structure
Link to this section Functions
Creates a new DomainEvent structure with a generated event_id
Examples
iex> DomainEvent.new("UserRegistered", %{name: "username", email: "user@example.com", createdAt: "2021-05-11T15:00:47.380Z"})
%DomainEvent{
data: %{
createdAt: "2021-05-11T15:00:47.380Z",
email: "user@example.com",
name: "username"
},
eventId: "852e6f59-f920-45e0-bce8-75f1e74647ff",
name: "UserRegistered"
}
Creates a new DomainEvent structure
Examples
iex> DomainEvent.new("UserRegistered", %{name: "username", email: "user@example.com", createdAt: "2021-05-11T15:00:47.380Z"}, "852e6f59-f920-45e0-bce8-75f1e74647aa")
%DomainEvent{
data: %{
createdAt: "2021-05-11T15:00:47.380Z",
email: "user@example.com",
name: "username"
},
eventId: "852e6f59-f920-45e0-bce8-75f1e74647aa",
name: "UserRegistered"
}