Colton Idle
03/14/2020, 2:25 PMerror: Dagger does not support injection into Kotlin objects
I'm admittedly someone still very new to dagger and so I'm not sure if I'm violating some overarching DI rules with trying to inject my moshi instance into my "util object". Can someone point me in the right direction of a solution? I suppose I can write extension methods instead of having this java util that was converted to a kotlin object?Paul Woitaschek
03/15/2020, 9:47 AMSinan Kozak
03/15/2020, 10:10 AMSinan Kozak
03/15/2020, 10:10 AMColton Idle
03/16/2020, 3:23 AMSinan Kozak
03/16/2020, 7:23 AMPaul Woitaschek
03/16/2020, 10:24 AMPaul Woitaschek
03/16/2020, 10:29 AMobject MySingleton{
class Deps @Inject constructor(
val depA : Int
)
lateinit var deps : Deps
}
fun initSingleton(){
MySingleton.deps = component.deps
}
Paul Woitaschek
03/16/2020, 10:29 AMJeremy
03/16/2020, 1:50 PM@Singleton
Colton Idle
03/17/2020, 1:47 PMPaul Woitaschek
03/17/2020, 1:52 PMJeremy
03/17/2020, 8:35 PMJeremy
03/17/2020, 8:36 PMSingleton
is not the same as static
and kotlin object
Colton Idle
03/18/2020, 3:51 PM@Singleton
. I'm instead trying to inject a singleton into that util so I can make sure it uses the same moshi instances. I guess at this point I'll just reevaluate the whole thing.Jeremy
03/18/2020, 4:49 PMobject
singletons to maintain global state but if you wanted to retain it you'd probably manually inject the moshiJeremy
03/18/2020, 4:49 PMColton Idle
03/19/2020, 1:33 AMobject
at hand doesn't handle any global state. It's just contains 4 util methods that rely on moshi to convert some json payloads to certain types.Sinan Kozak
03/19/2020, 6:28 AMPaul Woitaschek
03/19/2020, 9:47 AMPaul Woitaschek
03/19/2020, 9:47 AMColton Idle
03/19/2020, 3:07 PM