8000 [RFC] An unobtrusive EventDispatcher (not before 3.0) by mpdude · Pull Request #7792 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RFC] An unobtrusive EventDispatcher (not before 3.0) #7792

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

Closed
wants to merge 3 commits into from
Closed

[RFC] An unobtrusive EventDispatcher (not before 3.0) #7792

wants to merge 3 commits into from

Conversation

mpdude
Copy link
Contributor
@mpdude mpdude commented Apr 22, 2013
Q A
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? yes
Tests pass? not yet (if they do, coverage is not good enough :-)
Fixed tickets n/a
License MIT
Doc PR to-do

The idea of this PR is to separate the how of Event propagation from the what of Events.

Currently (2.x), client code has to inherit from Event to carry information about event propagation along. This is factored out into a separate class, EventPropagation.

The benefit for client code is that POPOs (anything) can be used as the Event and that these objects need not be aware of event dispatching at all. The object passed along is not modified during propagation, at least not by the Event Dispatcher system.

The new EventPropagation class is passed as the second argument to listeners. Besides stopping propagation, it allows to obtain both the EventDispatcher initially used to send off the Event (f. e. to trigger another one on the same channel) as well as the dispatcher a listener was registered with (in case a listener is multiply-subscribed and the dispatcher matters).

This is a spin-off from #7627 and we cannot get it before 3.0 due to API changes. Anyway, I'd like to start a discussion with it :-).

@fabpot
Copy link
Member
fabpot commented Apr 22, 2013

Closing this PR as this is not something I want to discuss at this point. see #7627 for more details.

@mpdude
Copy link
Contributor Author 8000
mpdude commented Apr 25, 2013

@fabpot Would you consider it if it only passed the additional EventPropagation object to listeners without other API changes or deprecations? (Not for 2.3 anymore)

@mpdude
Copy link
Contributor Author
mpdude commented Apr 9, 2014

Ping @perprogramming

@perprogramming
Copy link

+1! It is really a disadvantage of Symfony\Component\EventDispatcher that event objects have to extend a base class. It forces a bad coupling on client code..

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.

4 participants
0