serverlesstechnology / cqrs

A lightweight, opinionated CQRS and event sourcing framework.
Other
346 stars 36 forks source link

Empty event list being propagated to queries #91

Closed paulkre closed 4 months ago

paulkre commented 5 months ago

When you return Ok(vec![]) from an aggregate's handle() function, the aggregate's queries are being executed even though there are no events to be dispatched. You could argue that it is the query's responsibility to ignore an empty list of events, but the current implementation of GenericQuery does not do that and will instead always load a view, increment its version and save it whenever the query's dispatch() function is called, irrespective of its inputs.

I think it makes sense to change the behavior of CqrsFramework, so that it doesn't propagate any empty event lists coming from the aggregate's handle() function.

davegarred commented 4 months ago

Thank you for catching this @paulkre!!