Remove a callback from the given event.
(self, event, function)
| 63 | self.callbacks[event].append(callback_proto.adapt(function)) |
| 64 | |
| 65 | def unregister(self, event, function): |
| 66 | """Remove a callback from the given event.""" |
| 67 | if function in self.callbacks[event]: |
| 68 | return self.callbacks[event].remove(function) |
| 69 | |
| 70 | # Remove callback in case ``function`` was adapted by `backcall`. |
| 71 | for callback in self.callbacks[event]: |
| 72 | try: |
| 73 | if callback.__wrapped__ is function: |
| 74 | return self.callbacks[event].remove(callback) |
| 75 | except AttributeError: |
| 76 | pass |
| 77 | |
| 78 | raise ValueError('Function {!r} is not registered as a {} callback'.format(function, event)) |
| 79 | |
| 80 | def trigger(self, event, *args, **kwargs): |
| 81 | """Call callbacks for ``event``. |