eventHandler method
Apply an event to update the aggregate state This is called during both command processing and recovery
Implementation
@override
void eventHandler(Event event) {
try {
// Initialize state if needed
if (!isInitialized) {
_currentState = createInitialState();
}
// Apply the event to get new state
final newState = applyEvent(currentState, event);
// Update current state
_currentState = newState;
// Call event application hook
onEventApplied(event, newState);
} catch (e) {
onEventApplicationFailure(event, e);
rethrow;
}
}