I'm working on application with a C++ backend (models, business logic) and declarative UI in QtQuick.
Let's say I have an ItemModel, populated by running a query against a database (in the cloud). This model is then shown in the UI as a list. Now I want to have an operation which removes an Item from the list. What is the best way to handle it?
I can update the UI immediately as soon as the user removes an item, then remove it from the model, which then triggers an operation of removing the item from the database. This is fine, until the operation fails for some reason, and my model no longer matches the database.
On the other hand I can perform the database deletion first, then update the model based on the result and then update the UI. This ensures that the model, and view, is always in sync with the database, but can potentially result in unresponsive UI.
Aucun commentaire:
Enregistrer un commentaire