handle

abstract fun handle(cmd: COMMAND, events: List<EVENT>): EVENT?

Handle the COMMAND and decide if zero or one EVENT is returned as a result of handling the command

The handle method MAY also throw Exceptions if it's unable to handle the Command (e.g. due to invariant rules).

Command handling SHOULD be idempotent, meaning that if a Command has already been handled then the handle method MUST return zero Events as opposed to throwing an Exception.

Return

zero or one EVENT as a result of handling the command

Parameters

cmd

the command to handle

events

the event stream of past events associated with the Aggregate instance that is associated with the command (CAN be empty)