28 lines
587 B
Python
28 lines
587 B
Python
|
class Update:
|
||
|
def __init__(self):
|
||
|
self.message_queue = []
|
||
|
self.model = None
|
||
|
self.view = None
|
||
|
|
||
|
def update_model(self):
|
||
|
for msg in self.message_queue:
|
||
|
msg.update_model(self.model)
|
||
|
|
||
|
self.message_queue = []
|
||
|
self.view.view(self.model)
|
||
|
|
||
|
def schedule(self, msg):
|
||
|
self.message_queue.append(msg)
|
||
|
# for now, directly clearing message queue
|
||
|
self.update_model()
|
||
|
|
||
|
def set_model(self, model):
|
||
|
self.model = model
|
||
|
|
||
|
def set_view(self, view):
|
||
|
self.view = view
|
||
|
|
||
|
|
||
|
update = Update()
|
||
|
|