Hi cloudKVS users,
I'm updating my checklist app to share lists between users, and hope to use cloudKVS to do that - write changes to the local data store, let cloudKVS upload those to the server data store, and periodically refresh from server to the client app.
Question: When the NewData event fires (after a RefreshUser call), is there an easy way to determine which records have been updated?
For example, I'd like the UI to indicate that 4 updates happened, and the user could tap that to see which 4 records were affected.
My first thought was that the client could just remember the last time it got a NewData event, save that timestamp, and this time when new data came in, just loop through all items looking for ones that were updated since that time. (CloudKVS seems to have a timeField for each item, or I could add my own timestamp to each item.)
But when I started thinking about edge cases, I'm not sure this would work reliably. For example, when another client changes an item but their upload is delayed by network outage:
- 10am - They add item A and it uploads to the server.
- 11am - They add item B, but it doesn't upload yet because they're out of coverage.
- 12pm - I refresh and get item A (but not item B). I look for timestamps since my last refresh and find item A.
- 1pm - They return to coverage and item B uploads to the server.
- 2pm - I refresh and get item B. However, when I loop through items to get timestamps later than my last refresh (at 12pm), I don't find B (because its timestamp was 11am, based on when it was originally added to their local data store).
So not sure how I should handle this. I haven't found anything in the tutorial, comments, or on the forums. Anyone?