TaskRepository

interface TaskRepository

Repository abstraction for persisting task state across app restarts.

The primary use case is task recovery: On app restart, call getPending to find tasks that were interrupted and re-enqueue them via KmpWorker.enqueue.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun delete(id: String)

Removes a task from the store. Call after TaskState.Success.

Link copied to clipboard
abstract suspend fun getAll(): List<TaskRequest>

Returns all persisted tasks.

Link copied to clipboard
abstract suspend fun getById(id: String): TaskRequest?

Returns a single task by ID, or null if not found.

Link copied to clipboard
abstract suspend fun getPending(): List<TaskRequest>

Returns tasks with status PENDING or RUNNING. Use this on app restart to recover and re-enqueue interrupted tasks.

Link copied to clipboard
abstract suspend fun insert(task: TaskRequest)

Persists a new TaskRequest with status PENDING. No-ops if a task with the same ID already exists.

Link copied to clipboard
abstract suspend fun updateStatus(id: String, status: String, retryCount: Int)

Updates the status and retry count for a task.