2010-06-16 14:16:49 +00:00
|
|
|
class Observable(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.subscribers = []
|
|
|
|
def subscribe(self, subscriber):
|
|
|
|
self.subscribers.append(subscriber)
|
2010-06-17 19:52:21 +00:00
|
|
|
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)
|