Maestro.Aggregate.EventHandler behaviour (Maestro v0.5.0)

View Source

Minimal behaviour for a proper event handler. Like the CommandHandler, the use of the behaviour is not strictly required.

Summary

Callbacks

Event handlers must succeed in their application of the event. Validation and other forms of rejection/failure should be done in the command handler. This is made evident in the spec for apply in that the result should always be a new valid state.

Types

event()

@type event() :: Maestro.Types.Event.t()

Callbacks

apply(any, event)

@callback apply(any(), event()) :: any()

Event handlers must succeed in their application of the event. Validation and other forms of rejection/failure should be done in the command handler. This is made evident in the spec for apply in that the result should always be a new valid state.