Skip to content

Commit 23f0f21

Browse files
authored
fix: callback handlers for queue workers (#43)
When using a queue worker, each notification resets the scope. The problem here is that when this happens, all of the callbacks that were registered are no longer available - this is because they were all registered to a scoped singleton. I'm not sure how anyone else is able to use this package with a queue worker - out of the box it only works on "sync" mode, unless we remove the scoped singleton. In-fact, I'm curious as to why the singleton was scoped in the first place as part of the laravel 9 compatibility upgrades?
1 parent 82a4f15 commit 23f0f21

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/SubscribableServiceProvider.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,9 @@ public function boot()
3333
public function register()
3434
{
3535
$this->app->bind(MailChannel::class, SubscriberMailChannel::class);
36-
if (method_exists($this->app, 'scoped')) {
37-
$this->app->scoped(Subscriber::class, function (Application $app) {
38-
return new Subscriber($app);
39-
});
40-
} else {
41-
$this->app->singleton(Subscriber::class, function (Application $app) {
42-
/** @phpstan-ignore-next-line */
43-
return new Subscriber($app);
44-
});
45-
}
36+
$this->app->singleton(Subscriber::class, function (Application $app) {
37+
/** @phpstan-ignore-next-line */
38+
return new Subscriber($app);
39+
});
4640
}
4741
}

0 commit comments

Comments
 (0)