Access Event Store

Use Event Store directly

In some cases you may want to access Event Store directly. Event Store is auto registered in your Dependency Container, so you can fetch it like any other service or inject it directly to any Handler.

use Ecotone\EventSourcing\EventStore;
    public function getCurrentBalance(#[Reference] EventStore $eventStore): array
        $streamName = "wallet";
        if (!$eventStore->hasStream($streamName)) {
            return [];

        /** @var Event[] $event */
        $events = $eventStore->load($streamName, count: 10);

        return $events;

Last updated