79189857

Date: 2024-11-14 17:39:36
Score: 1.5
Natty:
Report link

Following the dagger documentation here

What you can do is using the @AssistedInject annotation and create a factory to be used.

class CustomClass @AssisgtedInject constructor (
    val repository: Repository, 
    @Assisted val name: String
) {

    @AssistedFactory
    interface CustomClassFactory {
        fun create(name: String): CustomClass
    }
}

Then you can have the @Inject CustomClassFactory and call the CustomClassFactory.create() to create your object.

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @AssistedInject
  • User mentioned (0): @Inject
  • Low reputation (1):
Posted by: Gab