Closed sandrokeil closed 5 years ago
I tried your solution already, but it will not work. Every $streamEvent generates 5 $data entries. See https://github.com/prooph/pdo-event-store/blob/master/src/PersistenceStrategy/PostgresSimpleStreamStrategy.php#L75-L90
So the result will be 5 if 1 streamEvent needs to persist.
According to: https://stackoverflow.com/a/22858509/919902
Generators are used to loop over them only once. A possible solution could be to count the streamEvents in the prepareData function and return the result of the count with the data array. But it's not a very neat solution.
What is the reason for using a Generator in event-engine/php-engine? Maybe that could be changed?
Sorry, didn't checked this.
See https://github.com/event-engine/php-engine/issues/6
I think we can use
\count($data)
here instead of\iterator_count($streamEvents)
to support Generators. Any concerns?