OfflineQueue
Offline-first task queue that persists tasks when the device is offline and automatically replays them when connectivity is restored.
Flow:
enqueue(request)
↓
isOnline?
↓ YES → execute immediately via KmpWorker
↓ NO → persist to TaskRepository (status = PENDING)
↓
network restored
↓
replay() → re-enqueue all PENDING tasksContent copied to clipboard
Recovery on app restart: Pending tasks survive app termination because they are persisted to SQLDelight. On next app start, call replay manually or ensure start is called so the queue can re-enqueue them.
Usage:
val queue = OfflineQueue(kmpWorker, repository, networkMonitor)
queue.start()
queue.enqueue(myTaskRequest)Content copied to clipboard