Replies: 2 comments
-
The PR is ready for review. Tests |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing this due a final resolution. Using |
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everybody and Laravel team.
With the announcement of the new helper
defer()
and with the spirit to contribute with something valuable to this community, I was checking the source code and noticed the ability to specify a name of the deferred callback so it can be cancelled later. However, I was unable to find where this actually can be cancelled.Ignoring whether this action is already implemented or not, I think it's valuable to have this ability next to the helper.
Proposed change
Add the ability to cancel deferred callbacks before they are executed. This can be achieved in two ways:
Option 1: Cancelling by name
Option 2: Cancelling directly
Implementation Details
I already have this done in my local environment, and would like to share with you my approach.
cancel()
method toDeferredCallback
class.cancel($name)
method toDeferredCallbackCollection
classinvokeWhen()
inDeferredCallbackCollection
to skip cancelled callbacksNote
With this approach, no changes are required to the
defer()
helper function 🎉🥳🎊Other additions
I also prepared a test suite to cover various scenarios:
Finally, I also made changes in the documentation to highlight this feature.
Realistic use case
Please consider this as a simple example, cancelling a defer method can be useful in many ways
Pull Request: #52816
Thanks,
Ronny
Beta Was this translation helpful? Give feedback.
All reactions