Hello all,
I’m new to this forum. Greetings!
I’m using EventSourcedBehavior in Java. When implementing the emptyState() method, does the method body need to create a new instance of the state, or is it ok to pass in the initial state as constructor parameter to EventSourcedBehavior?
It’s ok to pass in the initial state as constructor parameter, but it would be strange if it had different values over time for the same entityId.
The reason we named it emptyState rather than initialState was that it should represent the ”zero” and then all updates are via events.
Also, make sure to not share the state instance between different EventSourcedBehavior instances if the state is mutable.