I tried to learn from many CQRS frameworks created today. I saw that when a AR changes the state, we first store the event. Once the event is in event store we update the in memory AR object with the changes. Is there any reason we do this. In most of the CQRS implementations, the unit of work is tied to request thread using internalstatic object. So my question is it really necessary to update the AR object in memory once the event is stored in eventstore?
I have just started understanding the world of CQRS so may be the doubt may look stupid.
Having the Aggregate update in an event handler allows the Aggregate to be recreated from a list of historical events (the EventStore). If you update the internal state outside of event handlers, you may not be able to rebuild the Aggregate correctly.