Interface ChangeEventHandler<Command,State,ChangeEvent>
-
public interface ChangeEventHandler<Command,State,ChangeEvent>
API May Change: Implement this interface and use it inDurableStateBehavior#withChangeEventHandler
to store additional change event when the state is updated. The event can be used in Projections.The
updateHandler
anddeleteHandler
are invoked after the ordinary command handler. Be aware of that if the state is mutable and modified by the command handler the previous state parameter of theupdateHandler
will also include the modification, since it's the same instance. If that is a problem you need to use immutable state and create a new state instance when modifying it in the command handler.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ChangeEvent
deleteHandler(State previousState, Command command)
Store additional change event when the state is updated.ChangeEvent
updateHandler(State previousState, State newState, Command command)
Store additional change event when the state is updated.
-
-
-
Method Detail
-
updateHandler
ChangeEvent updateHandler(State previousState, State newState, Command command)
Store additional change event when the state is updated. The event can be used in Projections.- Parameters:
previousState
- Previous state before the update.newState
- New state after the update.- Returns:
- The change event to be stored.
-
deleteHandler
ChangeEvent deleteHandler(State previousState, Command command)
Store additional change event when the state is updated. The event can be used in Projections.- Parameters:
previousState
- Previous state before the delete.- Returns:
- The change event to be stored.
-
-