Summary
Offline writes sync later — last-write-wins loses data; need versioning, CRDTs, or server merge. UI shows conflict UI for unmergeable edits. IndexedDB + SW background sync patterns. E-commerce inventory cannot blindly LWW — business rules decide.
Code example
async function syncOfflineQueue() {
const pending = await db.getAll('outbox');
for (const op of pending) {
try {
await api.apply(op);
await db.delete('outbox', op.id);
} catch (err) {
if (err.status === 409) await showConflictUI(op);
}
}
}
Key points
- Offline writes sync later — last-write-wins loses data; need versioning, CRDTs, or server merge.
- UI shows conflict UI for unmergeable edits.
- IndexedDB + SW background sync patterns.
- E-commerce inventory cannot blindly LWW — business rules decide.