From a user POV I think it's a little bit confusing how to register plugins. The \Prooph\Snapshotter\SnapshotPlugin plugin is a good example. To register a plugin in the Event Store, each plugin must implement the setUp method.
public function setUp(EventStore $eventStore)
{
$eventStore->getActionEventEmitter()->attachListener('commit.post', [$this, 'onEventStoreCommitPost'], -1000);
}
Why don't we use an attach / detach method like Zend\EventManager has. I guess it's more intuitive to register the plugin in an Event Store instead of registering the Event Store in the plugin, which then registers the plugin in the Event Store with $eventStore->->getActionEventEmitter()->attachListener(...). The Event Store should implement.
public function attach($eventName, callable $listener, $priority = 1)
{
$this->actionEventEmitter->attachListener($eventNamer, $listener, $priority);
}
If we use this, I guess we also don't need to expose the action event emitter with getActionEventEmitter.
The same behavior is used for Service Bus plugins. Maybe we should switch it too? Here is an example
public function attach(ActionEventEmitter $emitter)
{
$this->trackHandler($emitter->attachListener(MessageBus::EVENT_INITIALIZE, [$this, 'onDispatchInitialize']));
}
From a user POV I think it's a little bit confusing how to register plugins. The
\Prooph\Snapshotter\SnapshotPluginplugin is a good example. To register a plugin in the Event Store, each plugin must implement thesetUpmethod.Why don't we use an
attach/detachmethod likeZend\EventManagerhas. I guess it's more intuitive to register the plugin in an Event Store instead of registering the Event Store in the plugin, which then registers the plugin in the Event Store with$eventStore->->getActionEventEmitter()->attachListener(...). The Event Store should implement.If we use this, I guess we also don't need to expose the action event emitter with
getActionEventEmitter.The same behavior is used for Service Bus plugins. Maybe we should switch it too? Here is an example