Skip to content

Instantly share code, notes, and snippets.

@DHosseiny
Last active May 26, 2023 13:37
Show Gist options
  • Save DHosseiny/c3737d933133db10845bb2bd82de6770 to your computer and use it in GitHub Desktop.
Save DHosseiny/c3737d933133db10845bb2bd82de6770 to your computer and use it in GitHub Desktop.
AggregatorWorkerFactory
/**
* This class aggregates hilt and dagger worker providers.
* TODO: This class can get removed when fully migrated to hilt
*/
class AggregatorWorkerFactory(
private val hiltWorkerFactory: HiltWorkerFactory,
private val daggerWorkerFactory: DaggerWorkerFactory
) : WorkerFactory() {
override fun createWorker(
appContext: Context,
workerClassName: String,
workerParameters: WorkerParameters
): ListenableWorker? {
return hiltWorkerFactory.createWorker(appContext, workerClassName, workerParameters)
?: daggerWorkerFactory.createWorker(appContext, workerClassName, workerParameters)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment