[13.x] Allow auto discovered listeners to opt out of discovery#60209
Open
jackbayliss wants to merge 3 commits into
Open
[13.x] Allow auto discovered listeners to opt out of discovery#60209jackbayliss wants to merge 3 commits into
jackbayliss wants to merge 3 commits into
Conversation
import dis tests i changed da name
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Good day!
This PR adds a
ShouldBeDiscoveredinterface that lets listeners decide themselves if they should be registered during discovery... used an interface so I'm not causing any B/C.I want auto discovery, cause it's easy, but I want to purposefully not register some events in certain environments, I can do it in the handle, but it felt repetitive so thought this could be nice... as avoids discovery completely
This is especially helpful for listeners that implement ShouldQueue, as it's not completely obvious the logic in the handle will still get queued.
Code example:
Details
Idea being it just stops it being discovered at all.., no need to think about shouldQueue, we just dont want it for this env..
Why not just use a subscriber? ... Cause generally you use it to subscribe for multiple events, if you only have one, it feels (at least to me) a bit overcomplicated. I wanna let the auto discover handle it.
Also don't really wanna Event:forget as that too feels a bit.. meh
I just want a way to say "Dont listen to this.. due to XYZ" - ie a environment, feature etc. This provides a lightweight alternative essentially. The method is purposefully static to not rely on state.
Note- you can still manually Event::listen, but this is about automagic discovery! This also works with optimize etc
Open to renaming, a better way, or throwing this away I am but one man from England with ideas!