Skip to content

event-sourcing-starter ​

Events Reducer ​

An event reducer using a non-empty list design to build value object projections.

The [factory] is used to handle the initial event, it produces the initial state of the projection. The derived state is used as the seed on which to apply the rest of the events.

The remaining events are handled by folding functions that take the current state of the projection, the current event, and return an updated state to be used for the next event.

You can [register] an event-specific folding function, if no specific function has been registered, the event will be handled by the mandatory [defaultHandler].

If you register multiple specific handlers for the same class only the last registered handler will be used.

Class: com.drinkit.event.sourcing.EventsReducer

Methods (3)
  • reduce()
  • register() - Register a handler for the given event type.
  • register() - Register a handler for the given event type using a method reference. This allows for simplified syntax like: register<EventType>(Projection::methodName)

History ​

Represents a chronological sequence of domain events, starting with an initial event.

This class is useful for:

  • Maintaining the complete history of an entity
  • Ensuring there is always an initial event
  • Ensuring events are processed in the correct order
  • Providing a clean separation between the initial creation event and subsequent events

Class: com.drinkit.event.sourcing.History


Generated automatically from code annotations

MIT Licensed