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

Events in the global namespace #1

Open
tlmcclatchey opened this issue Feb 17, 2024 · 0 comments
Open

Events in the global namespace #1

tlmcclatchey opened this issue Feb 17, 2024 · 0 comments
Labels
question Further information is requested

Comments

@tlmcclatchey
Copy link
Member

tlmcclatchey commented Feb 17, 2024

Events could be available globally, not just on the class level; or it could be on both?

For instance, having a $database->onConnect(...) event caller is handy and segregates the event from something like $configuration->onLoad(...).

Perhaps a better way to do this would be to have $events->on('database.connect', ...) and $events->on('config.load', ...)?

The benefit to this is that you could potentially check if an event exists without having to reference the target class. This would allow for further decoupling so that, in the event of a database, you could use $events->hasEvent('database.connect') and, if that returns false, you could use $events->hasNamespace('database') to see if there are even any events in that namespace.

The issue with this, however, is that it could cause naming collisions if two libraries decide on using the same namespace. This would require extra checks to ensure that parameters exist and match.

@tlmcclatchey tlmcclatchey added the question Further information is requested label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant