Closed christianbrugger closed 9 years ago
That's why state changes should only be reported to the backend after they are completed and items should not directly apply them while they are being modified in the value in question. If the metadata that changes isn't repropagated you have no way to make sure that the UI stays in sync with the backend. Especially if you ever want to have multiple frontends to one backend.
The ideal state is to optimistically apply changes directly to the frontend element as the user performs them (during interaction the user is in control) but to always become eventually consistent with the authoritative state in the backend.
I resolved this issue by not sending all state changes to the backend. But rather introduce some sync points in the GUI where all changes are collected and send in a batch to the backend. Such sync points are currently performed when changing modes (e.g. going from selection to edge triggering).
Currently when notifying the backend on a metadata update through
Interface.update_element
causes the backend to report back the metadata update viaInsertableItem.update
. This loop causes serious issues.@hacst: I propose that the backend only reports on metadata changes induced from the backend, e.g. on item creation, when additional fields are set or when logic states change, but not on updates from the specific frontend / GUI.
One issue with the current approach is, that it is not clear anymore to the
InsertableItem
whether to apply a change or not, when multiple updates have been scheduled. Imagine the following situation. An element is moved quickly with the mouse fromx=0
to1
and finally2
. The element issues two updates to the backend:{'x': 1}
and a few ms later{'x': 2}
. Then after a while the backend reports an updated position viaInsertableItem.update({'x': 1})
. The item being at positionx=2
has now to assume that it has to move to positionx=1
, causing an unnecessary state change. This is more serious for large moves and makes the GUI seem to misbehave (stuttering). That is why the backend should never report back on incoming updates.