As far as I know, this looks like an Observer pattern. Scenario: A Center object stores a list (queue) of all its clients. I am using Twisted.
- One of the client objects changes the variable in the center of the object OR notifies the center of the change of the variable,
- and then the central object will immediately detect the change ;
- then, as soon as detection, the central object calls some function of the next object in the queue
- After the client changes the variable, the client object will be deleted. The center will take care of the next client facility. Therefore, I do not assume that there is no functional chain between these objects. So this is a little different from the observer pattern. (How to solve this problem? Correct me if I am wrong.)
The following code is for demonstration purposes 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
def whenChanged(self):
next = self.queue.dequeue()
next.function()
Henry source
share