I have a hybrid application that is available on android and through browsers. Both clients use the REST API and websockets. Data is stored in localStorage. I would like the mobile devices to be able to modify offline resources, and after connecting to the Internet the data was synchronized with the API.
How to make such a comparison of data after connecting to the Internet and get the right version?
Problem scenario:
- User has a list of notes fetched from the API on the phone.
- User turns off the Internet
- User remains logged in with the JWT token. Modifies a note, deletes another note, adds a new one or does anything else with the notes
- User turns on the Internet.
- What should happen here?
My ideas on how to solve this problem:
- creating a synchronization endpoint and comparing collections by updated_at column when connection is received.
- compare objects for difference with this utility