Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Adds closure support to dispatch conditionals. #43784

Merged
merged 3 commits into from Aug 22, 2022
Merged

[9.x] Adds closure support to dispatch conditionals. #43784

merged 3 commits into from Aug 22, 2022

Conversation

DarkGhostHunter
Copy link
Contributor

What?

Enables usage of closures to dispatch a job conditionally. The closure will receive the job arguments.

MyQueuableJob::dispatchIf(Something::check(...), $name);

Also adds tests both dispatchIf and dispatchUnless.

@taylorotwell
Copy link
Member

@DarkGhostHunter

IMO the entire job instance should be passed to the closure. I have updated the PR. Thoughts?

@DarkGhostHunter
Copy link
Contributor Author

DarkGhostHunter commented Aug 21, 2022

I don't have too much of maneuverability if I get the job instance full of non-public members, so it would force me to:

a) make a public method for additional checks.
b) make its properties public.

Since these are small chores, I can see it can be more convenient and forces me to push part of the check in the instance itself.

I approve these changes.

@taylorotwell taylorotwell merged commit 8453ed8 into laravel:9.x Aug 22, 2022
@DarkGhostHunter DarkGhostHunter deleted the feat/dispatch-condition-callable branch September 8, 2022 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants