Connects the event with the given callback. When the signal is emitted, the callback is invoked. .. note:: The signal handler is stored with a hard reference, so you need to make sure to call :class:`disconnect()` if you want the handler
(self, callback, *args, **kwargs)
| 63 | return self.emit(*args, **kwargs) |
| 64 | |
| 65 | def connect(self, callback, *args, **kwargs): |
| 66 | """ |
| 67 | Connects the event with the given callback. |
| 68 | When the signal is emitted, the callback is invoked. |
| 69 | |
| 70 | .. note:: |
| 71 | |
| 72 | The signal handler is stored with a hard reference, so you |
| 73 | need to make sure to call :class:`disconnect()` if you want the |
| 74 | handler |
| 75 | to be garbage collected. |
| 76 | |
| 77 | :type callback: object |
| 78 | :param callback: The callback function. |
| 79 | :type args: tuple |
| 80 | :param args: Optional arguments passed to the callback. |
| 81 | :type kwargs: dict |
| 82 | :param kwargs: Optional keyword arguments passed to the callback. |
| 83 | """ |
| 84 | if self.is_connected(callback): |
| 85 | raise AttributeError('callback is already connected') |
| 86 | if self.hard_subscribers is None: |
| 87 | self.hard_subscribers = [] |
| 88 | self.hard_subscribers.append((callback, args, kwargs)) |
| 89 | |
| 90 | def listen(self, callback, *args, **kwargs): |
| 91 | """ |