pywayland
pywayland copied to clipboard
Feature request: Add method to Signal which removes all listeners
It's very common that all listeners should be removed from a signal if i.e. a Keyboard, Output, or Pointer is destroyed.
Currently one method to remove all listeners is:
def remove_listeners(sig: Signal):
for listener in sig._link[:]:
listener.remove()
It would be nice if Signal provides an API for that, i.e.:
def remove_listeners(self) -> None:
"""
Removes all listeners from this signal.
"""
for listener in self._link[:]:
listener.remove()
I'd provide a PR if you think this is a valuable addition.