Thread
#dagger
    dave08

    dave08

    8 months ago
    Why doesn't Hilt provide a
    @WorkComponent
    for WorkManager workers? Is there a way to make my own? Or is it intended, and there's something different to do for workers?
    Colton Idle

    Colton Idle

    8 months ago
    I don't use workmanager, but no one from the workmanager/hilt team is here, so I doubt you will get an answer to your question. I'd file a bug/feature request. Also, there seems to be some sort of integration available in the docs: https://developer.android.com/training/dependency-injection/hilt-jetpack#workmanager
    FunkyMuse

    FunkyMuse

    8 months ago
    Basically WorkManager has assisted injected constructor, you can put there dependencies that live in your custom scope
    t

    trevjones

    8 months ago
    WorkerFactoryModule
    is install to Singleton and the `androidx.work.Configuration`` is used to initialize inside of a double check lock to ensure a single instance of the factory is created. Which should mean that the only safe scope to depend on is
    Singleton
    or unscoped. Scoping the worker itself seems bad given each invocation is going to get its own instance of
    WorkerParameters
    dave08

    dave08

    8 months ago
    Yeah, but all worker dependencies are going to live throughout application life... So if multiple dependencies depend on one other, it's either create ot twice, or make it live during the application's lifetime...