mtg/observable.py

10 lines
329 B
Python

class Observable(object):
def __init__(self):
self.subscribers = []
def subscribe(self, subscriber):
self.subscribers.append(subscriber)
def unsubscribe(self, subscriber):
self.subscribers.remove(subscriber)
def emit(self, *args):
for fn in self.subscribers:
fn(*args)