[13.x] Add #[AfterCommit] attribute - #61208
Conversation
|
|
||
| namespace Illuminate\Contracts\Broadcasting; | ||
|
|
||
| interface ShouldBroadcastAfterCommit extends ShouldBroadcast |
There was a problem hiding this comment.
What about ShouldBroadcastNow?
There was a problem hiding this comment.
After-commit only makes sense for queued broadcasts — ShouldBroadcastNow bypasses the queue, so afterCommit would never be read
|
Would an |
|
@gdebrauwer It might be, but it'd need to cover jobs, mailables, notifications and listeners too — they all use interfaces today (ShouldQueueAfterCommit, ShouldDispatchAfterCommit, ShouldHandleEventsAfterCommit), so an attribute only for broadcasts would be inconsistent. |
|
@xurshudyan If we only ever did what has been done before, there would be no change. Someone always have to make the first step. |
ShouldBroadcastAfterCommit contract#[AfterCommit] attribute
|
Here we go again — #[AfterCommit], attempt 3. 😄 |
Adds an #[AfterCommit] attribute for deferring queued work until the open database transaction commits.
It works anywhere the $afterCommit property already does — queued jobs, listeners, mailables, notifications and broadcast events — and can still be overridden with public $afterCommit = false; or ->beforeCommit().