Skip to content
Snippets Groups Projects
Unverified Commit f83589f7 authored by Christoph Wurst's avatar Christoph Wurst Committed by GitHub
Browse files

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

Allow to remove listeners
parents 72cc8270 3ffed429
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,11 @@ class EventDispatcher implements IEventDispatcher { ...@@ -63,6 +63,11 @@ class EventDispatcher implements IEventDispatcher {
$this->dispatcher->addListener($eventName, $listener, $priority); $this->dispatcher->addListener($eventName, $listener, $priority);
} }
public function removeListener(string $eventName,
callable $listener): void {
$this->dispatcher->removeListener($eventName, $listener);
}
public function addServiceListener(string $eventName, public function addServiceListener(string $eventName,
string $className, string $className,
int $priority = 0): void { int $priority = 0): void {
......
...@@ -42,6 +42,14 @@ interface IEventDispatcher { ...@@ -42,6 +42,14 @@ interface IEventDispatcher {
*/ */
public function addListener(string $eventName, callable $listener, int $priority = 0): void; 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 $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 * @param string $className fully qualified class name (or ::class notation) of a \OCP\EventDispatcher\IEventListener that can be built by the DI container
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment