-
Notifications
You must be signed in to change notification settings - Fork 4
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
Why there is no removeListener() method? #5
Comments
Could you please explain your use case why is it needed? |
Maybe my use case is somewhat constructed, but I have set up a comand bus decorator via an di container (php-di) which allows me to access the event dispatcher through a public method. I have also created an event which is then triggered in the command handler when a record is deleted. If a client (listener) is interested in that event it calls the public method, gets the event dispatcher and registers itself to be notified. To test that, I’ve written two test methods, one which wants to be notified and another one which just tests the successful execution of the command. As the command bus and therefore the event dispatcher are not destroyed between the two test methods, the test method which not wants to be notified becomes also notified, because the listener is still active in the listener array from the first call to addListener(). As code says more then 1000 words, here some sample code:
I helped myself by reimplementing a class which uses the EventDispatcherInterface and ContainsListenersInterface and of course added the removeListenerMethod($eventName, $listener).
Hopefully, that makes sense. |
No description provided.
The text was updated successfully, but these errors were encountered: