pywayland icon indicating copy to clipboard operation
pywayland copied to clipboard

Feature request: Add method to Signal which removes all listeners

Open heuer opened this issue 10 months ago • 0 comments

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.

heuer avatar Apr 09 '24 11:04 heuer