A way to delay a callback until after the current transaction has committed successfully #4118
diesieben07
started this conversation in
Feature Requests & Ideas
Replies: 1 comment
-
Great timing, was also looking for similar behavior today. Another use case is where a side effect requires the mongo data to be written and available. In my particular use case I have a side effect that needs to be run after |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It would be useful to have a way to delay code until after the current transaction is committed. The use-case for this are external effects that happen as a result of an "after change" hook or similar. I am currently adding push notifications to a backend using Payload, which should be sent whenever there is a new document in a specific collection. If I send out the notification in an "after change" hook, but then transaction rolls back, I have just sent out a notification for something that doesn't actually exist.
Prior Art
transaction.on_commit
TransactionalEventListener
DB::afterCommit
(I couldn't find the docs about this, but here is a blog post: https://divinglaravel.com/better-management-of-database-transactions-in-laravel-8)The way this could be implemented is to store an array
transactionCallbacks
inPayloadRequest
and havecommitTransaction
execute them after committing.Beta Was this translation helpful? Give feedback.
All reactions