OnePiece.Commanded.Aggregate behaviour (OnePiece.Commanded v0.1.1)
View Source
Apply a given event to the aggregate returning the new aggregate state.
Convert the module into a Aggregate
behaviour.
Specs
apply(aggregate :: t(), event :: event()) :: t()
Apply a given event to the aggregate returning the new aggregate state.
Example
def apply(account, event) do
account
|> Map.put(:name, event.name)
|> Map.put(:description, event.description)
end
Convert the module into a Aggregate
behaviour.
Usage
defmodule Account do
use OnePiece.Commanded.Aggregate
@impl OnePiece.Commanded.Aggregate
def apply(account, event) do
account
|> Map.put(:name, event.name)
|> Map.put(:description, event.description)
end
end