Skip to content

Commit

Permalink
Use scoped singletons where appropriate (#149)
Browse files Browse the repository at this point in the history
* Use scoped singletons where appropriate

* Fix styling
  • Loading branch information
inxilpro authored Jul 9, 2024
1 parent 0c32ee9 commit c231409
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/VerbsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ public function registeringPackage()

public function packageRegistered()
{
$this->app->singleton(Broker::class);
$this->app->singleton(Dispatcher::class);
$this->app->singleton(EventStore::class);
$this->app->scoped(Broker::class);
$this->app->scoped(Dispatcher::class);
$this->app->scoped(EventStore::class);
$this->app->singleton(SnapshotStore::class);
$this->app->singleton(EventQueue::class);
$this->app->singleton(EventStateRegistry::class);
$this->app->scoped(EventQueue::class);
$this->app->scoped(EventStateRegistry::class);
$this->app->singleton(MetadataManager::class);

$this->app->singleton(StateManager::class, function (Container $app) {
$this->app->scoped(StateManager::class, function (Container $app) {
return new StateManager(
dispatcher: $app->make(Dispatcher::class),
snapshots: $app->make(StoresSnapshots::class),
Expand Down Expand Up @@ -129,7 +129,7 @@ classDiscriminatorResolver: new ClassDiscriminatorFromClassMetadata(new ClassMet
);
});

$this->app->singleton(AutoCommitManager::class, function (Container $app) {
$this->app->scoped(AutoCommitManager::class, function (Container $app) {
return new AutoCommitManager(
broker: $app->make(BrokersEvents::class),
enabled: $app->make(Repository::class)->get('verbs.autocommit', true),
Expand Down

0 comments on commit c231409

Please sign in to comment.