As far as I know, this is like an Observer pattern. Scenario: A Center object keeps a list (queue) of all its clients. I'm using Twisted.
- One of client objects changes a variable in center object OR notify the center to change the variable,
- and then the center object detects the change immediately;
- then as soon as the detection, the center object invoke some function of next object in queue
- After the client changed the variable, the client object will be eliminated. The center will take care of next client object. So I imagine there's no any function chain between these objects. So it's a little bit different from observer pattern. (How to address this issue? Correct me if I'm wrong.)
following code is just for demo only:
class client():
def change(self):
self.center.va = 1
def inqueue(self):
self.center.queue.enqueue(self)
def function(self):
pass
class center():
def __init__(self):
self.queue = None
self.va = 0
#### When the self.va changes, this func will be invoked
def whenChanged(self):
next = self.queue.dequeue()
next.function()