The Observer pattern has two roles: a Subject that holds a list of interested parties, and observers that want to be told when something happens. Everything reactive, event buses, signals, UI frameworks, is built on this one idea.
Here an observer is just a callable. Implement the broadcast.
notify(*args): call every subscribed observer with args, in subscription orderclass Subject:
def __init__(self):
self._observers = []
def subscribe(self, observer):
self._observers.append(observer)
def notify(self, *args):
"""Call every observer with args, in subscription order."""
# TODO:
# for observer in self._observers:
# observer(*args)
pass
The editor and the test runner need a wide screen. Open this page on a desktop browser and your progress will be waiting.
The Observer pattern has two roles: a Subject that holds a list of interested parties, and observers that want to be told when something happens. Everything reactive, event buses, signals, UI frameworks, is built on this one idea.
Here an observer is just a callable. Implement the broadcast.
notify(*args): call every subscribed observer with args, in subscription orderPress Run Tests or ββ© to check your solution.