SyncWorker

class SyncWorker @AssistedInject constructor(@Assisted context: Context, @Assisted workerParameters: WorkerParameters, ioDispatcher: CoroutineDispatcher, homeRepository: HomeRepository) : CoroutineWorker(source)

Collects the repository's push-then-pull sync Flow and updates foreground notification counts.

The repository owns persistence and conflict behavior. Completion does not establish that concurrent edits or every remote record were delivered. Exceptions request retry while runAttemptCount is below TOTAL_SYNC_ATTEMPTS; the broad catch includes cancellation.

WorkManager supplies assisted parameters; Hilt supplies the dispatcher and repository.

Parameters

context

Application context provided by WorkManager.

workerParameters

Runtime parameters provided by WorkManager.

ioDispatcher

Dispatcher for sync work.

homeRepository

Repository implementing the sync algorithm.

Constructors

Link copied to clipboard
@AssistedInject
constructor(@Assisted context: Context, @Assisted workerParameters: WorkerParameters, ioDispatcher: CoroutineDispatcher, homeRepository: HomeRepository)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open suspend override fun doWork(): ListenableWorker.Result

Collects sync progress on ioDispatcher and updates foreground counts.

Link copied to clipboard
open suspend override fun getForegroundInfo(): ForegroundInfo

Provides foreground information for the sync worker with default progress.