-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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 partial wildcard matching #3250
Comments
This doesn't apply to Yii because Yii doesn't use global events (although you can emulate that by registering events with the application instance). Also partial matching will degrade performance, especially when events are triggered on the critical path. |
What is the usecase of subscribing to arbitrary events? How does your code know how to handle it if it is not know before which event will come? |
@cebe use case is to manage entity when some event with it occurs, in the example above we may need to log / filter some additional information without particular khowing what event occured, the thing that matters is that user was changed. @qiangxue currently i dont see any critical path in Yii that can have some trouble with it. With such feature we also dont bind to classes and application structure, because |
Along the critical path, we are triggering many events. And whenever an event is triggered, the wildcard matching logic would be involved and every such handler needs to be examined. There is no fundamental difference between a class name and a name like |
@qiangxue but if not using application as event manager, but using |
When you write names like |
it is different, because |
Regarding the performance issue, this is a global event, meaning that whenever you trigger an event, these global event handlers need to be checked to see if they match the event currently being triggered. So this feature, while may be useful, doesn't scale well and should not be promoted. Using the current class-level events, you can trigger an event like |
ok, will skip wildcard matching ) |
It will be great if events will be also partially matched, so user can subscribe to some events like:
in the above user subscribed to all events from
user.*
likeuser.signup
,user.resetPassword
,user.login
or other.Similar functionality presents in other framework and is very useful. However maybe we need to create some helper for partial matching, since it can be widely used: message translations, events, loading fixtures by partial match, and other.
The text was updated successfully, but these errors were encountered: