Colton Idle
05/24/2024, 5:01 PM@Module
@InstallIn(SingletonComponent)
interface MyModule {
companion object {
@Provides
@Singleton
fun provideThing(builder: MyBuilder): Thing = builder.build()
}
}
I'm not sure of the reason why this is an interface with a companion object. Can someone explain why?
Additionally... if I wanted to add a new provides method for a simple Foo object would I just do
@Provides
fun provideFoo() = Foo()
inside of the companion object, or outside of the companion?Nicholas Doglio
05/24/2024, 5:22 PM@Binds
method defined in the interface or they plan to have one added later?
Additionally... if wanted to add a nevw provides method for a simple Foo object would just do
@Provides fun provideFoo() = Foo()
inside of the companion object, or outside of the companion?
Inside the companion object! Although if Foo is an object you own you should just update its constructor to use
@Inject
and avoid the provides method entirely.Colton Idle
05/24/2024, 5:28 PMthey plan to have one added later?Gotcha. so almost like "future proofed" in a way
Inside of the companion objectAwesome. thank you! and good point on just putting @Inject. lol.