I was asked this question at the recent Tokyo ideathon, and wanted to see if anyone had ideas for better approaches.
Problem: how can you indicate in an app whether a document has been pushed to the sync gateway yet?
A possible solution to this is to have a field which tracks this, and something that is listening to the sync gateway changes feed would update that field. Here's how the step-by-step would look:
1. Add a new field to the document you care about, called "pushed". It would start out as pushed: false in the JSON.
2. Add a _changes listener that followed the sync gateway changes feed. This would run on a backend server that has access to the Sync Gateway. (An example changes listener for TodoLite demo app can be seen
here)
3. When the _changes listener saw a document with "pushed: false", it would update the document to "pushed: true"
4. The Couchbase Lite database would pull the updated version of the document, which is now "pushed: true", and the UI of the app would indicate to the user whether or not the document has been pushed.
My main question is: is there a better way to do this?
I was discussing w/ Zack and he had some other ideas, which hopefully he'll throw out. If anyone has suggestions, I'd love to hear it.
PS: Once we figure out a best practice here, I think we should add this feature to TodoLite.