mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-15 10:22:26 +12:00
24 lines
492 B
Python
24 lines
492 B
Python
|
|
class Signal():
|
|
def __init__(self) -> None:
|
|
self._methods = []
|
|
|
|
def connect(self, func):
|
|
self._methods.append(func)
|
|
|
|
def disconnect(self, func):
|
|
try:
|
|
self._methods.remove(func)
|
|
except ValueError:
|
|
raise TypeError
|
|
|
|
def disconnect(self):
|
|
if len(self._methods) == 0:
|
|
raise TypeError
|
|
self._methods.pop()
|
|
|
|
def fire(self, data):
|
|
for m in self._methods:
|
|
m(data)
|
|
|