mtg/observable.py

11 lines
329 B
Python
Raw Permalink Normal View History

2010-06-16 14:16:49 +00:00
class Observable(object):
def __init__(self):
self.subscribers = []
def subscribe(self, subscriber):
self.subscribers.append(subscriber)
def unsubscribe(self, subscriber):
self.subscribers.remove(subscriber)
2010-06-16 14:16:49 +00:00
def emit(self, *args):
for fn in self.subscribers:
fn(*args)