Live UI update of model changes when the model contains only simple data structures
Consult me ββwith your views on the following topic:
I have a model - a structure of objects. For example:
-
Event containing participants
-
Current task
-
Purpose of each task
The model will be marinated on the server and transmitted over the network to the client graphics application. Because of the pickle, I would like to keep the model classes as simple as possible (i.e. Just simple classes with only data fields, no method inside). As a result, I cannot generate signals (such as OnUpdate) for model objects.
Sometimes the server sends model updates. Such as "The text of the problem has changed." When an update is applied, I need it to be reflected in the UI. If you change the text of the task, this should be a change to the label in the user interface. I would like to have only related controls changed, so updating the entire UI is not the best solution.
On the other hand, I would not like to move the entire model in search of changes - it would be too resource intensive.
So what's the best example of notifying the UI of changes to simple data structures?
source to share
You can add a flag for example. self.isOnClientSide, and check it in each update handler so you can use different logic anyway.
def onUpdateFoo(self):
if self.isOnClientSide:
return self.onUpdateFooOnClient()
else:
return self.onUpdateFooOnServer()
Change this checkbox accordingly immediately after untangling.
source to share