I want to make an Offline-first application. I am considering using standard CoreData for that. The collaborative and syncing features are to be handled through Parse.
To keep my CoreData in sync, I expect to
- need to monitor for changes (LiveQueries)
- download changed objects at launch (get all objects changed since last sync)
- upload changes as they happen, retry when entering background/launching the app if it failed
I’ll probably going to use some hashing of the data + recipe.updatedAt to detect conflicts. I’ll adopt a last change wins strategy to start but I’ll investigate a “merge UI”. I don’t expect concurrent edits to happen that often, I only need to handle offline editing/bad network.
My question resides around deletes. I’ll see them with the LiveQuery but only when the app is running. What about deletes that happens when the app isn’t running? I could run a query for all recipes IDs and compare them, delete anything that is missing. I don’t expect users to have more than 5000 records, so in the end this isn’t too expensive but I wonder if there’s a better solution?
I could leave records in place instead of deleting them and mark recipes with a isDelete column but then they’ll be forever there.
Suggestions?