Merge pull request #19670 from nextcloud/techdebt/noid/allow-to-remove-listeners

Allow to remove listeners
This commit is contained in:
Christoph Wurst 2020-02-27 13:08:42 +01:00 committed by GitHub
commit f83589f75d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -63,6 +63,11 @@ class EventDispatcher implements IEventDispatcher {
$this->dispatcher->addListener($eventName, $listener, $priority);
}
public function removeListener(string $eventName,
callable $listener): void {
$this->dispatcher->removeListener($eventName, $listener);
}
public function addServiceListener(string $eventName,
string $className,
int $priority = 0): void {

View File

@ -42,6 +42,14 @@ interface IEventDispatcher {
*/
public function addListener(string $eventName, callable $listener, int $priority = 0): void;
/**
* @param string $eventName preferably the fully-qualified class name of the Event sub class
* @param callable $listener the object that is invoked when a matching event is dispatched
*
* @since 19.0.0
*/
public function removeListener(string $eventName, callable $listener): void;
/**
* @param string $eventName preferably the fully-qualified class name of the Event sub class to listen for
* @param string $className fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container