View Source OnePiece.Commanded.Aggregate behaviour (OnePiece.Commanded v0.10.0)
Defines the an OnePiece.Commanded.Aggregate
behaviour.
Link to this section Summary
Callbacks
Apply a given event to the aggregate returning the new aggregate state.
Functions
Convert the module into a Aggregate
behaviour.
Link to this section Types
Link to this section Callbacks
Apply a given event to the aggregate returning the new aggregate state.
example
Example
def apply(account, event) do
account
|> Map.put(:name, event.name)
|> Map.put(:description, event.description)
end
Link to this section Functions
@spec __using__(opts :: []) :: any()
Convert the module into a Aggregate
behaviour.
usage
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