evoq_event behaviour (evoq v1.14.1)

View Source

Event behavior for evoq.

Events represent facts that have happened. They are: - Past tense: account_opened, money_deposited - Immutable once stored - Produced by aggregates in response to commands - Domain artifacts: atom keys, Erlang terms, stay inside bounded context

Required Callbacks

- event_type() -> atom() - new(Params) -> Event - to_map(Event) -> map()

Optional Callbacks

- from_map(Map) -> {ok, Event} | {error, Reason}

Summary

Callbacks

event_type/0

-callback event_type() -> atom().

from_map/1

(optional)
-callback from_map(Map :: map()) -> {ok, Event :: term()} | {error, Reason :: term()}.

new/1

-callback new(Params :: map()) -> Event :: term().

to_map/1

-callback to_map(Event :: term()) -> map().