Chronik v0.1.2 Chronik.Macros View Source
This module provides a number of utility macros used along Chronik.
Link to this section Summary
Functions
The defcommand
an utility macro used to define the handle_command
callback
The defevent
macro is used to define domain events that go into
the Store and the PubSub.
For example:
defevent(CounterIncremented, [:id, :increment])
Link to this section Functions
The defcommand
an utility macro used to define the handle_command
callback.
For example the function:
def handle_call({:create, id}) do
__MODULE__.call(id,
fn state ->
state
|> execute(&create_validator(&1, id))
end)
end
can be define with this macro as:
defcommand create(id) do
fn state ->
state
|> execute(&create_validator(&1, id))
end)
end
This macro also defines a create(id)
function which calls the handle_call
so the user can call __MODULE__.create(1234)
.
The defevent
macro is used to define domain events that go into
the Store and the PubSub.
For example:
defevent(CounterIncremented, [:id, :increment])