1

I'm new to this community, I'm glad I found this and so I can ask questions like this one (as per https://meta.stackexchange.com/questions/68384/whats-the-difference-between-stack-overflow-and-software-engineering-se-previo).

The problem is simple, how do I fetch the data in an app's home screen if I do offline-first type?

Sample project for context: A simple Notes App. Home screen: loads all the list of the Notes (with tile and cut-off content text).

I'm doing a simple notes-ish project, and I need to make it offline-first. I mean it does support offline using database. (SQLite). And when the app gets online, it will upload the saved offline data to the server.

TL;DR, question: in an offline-first app, do I GET/fetch the homescreen data from the SERVER or from the LOCAL DB? Both when the device is online and offline.

1

do I GET/fetch the homescreen data from the SERVER or from the LOCAL DB?

Yes.

When offline, fetch it from the local database.

When you first come online, sync the data with the server.

If already online, sync the data if it hasn't been sync'd by the end of the last user session.

If already online and you have already sync'd the data at the end of the last session, just fetch it from the server. All though if you have a good synchronization algorithm you could just always sync the data at start-up if you are online, and sync the data as soon as you come back online after going offline.

  • Thanks a lot! I've been looking for this kind of simple and straightforward instruction. – Glenn Sep 19 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.