evant
06/15/2021, 2:55 PMTestFakes
class and do:
@Component
@ApplicationScope
abstract class TestApplicationComponent(
@get:Provides val episodesDao: EpisodesDao = FakeEpisodesDao(),
@get:Provides val songsDao: SongsDao = FakeSongsDao(),
)
but the problem is that due to a limitation with kapt/ksp the generated create()
method can't forward default args, so you are stuck with providing all of them.
So yeah @Component
was meant to take a parent component to obtain additional bindings from, but I ended up not requiring the annotation on it because it can be useful at times to abstract out what's passed as a parent and the actual impl, for example in a multimodule setup.
interface MyParentComponent {
@get:Provides val foo: Foo
}
@Component
abstract class MyParentComponentImpl : MyParentComponent { ... }
I discovered that this flexibility works for this use-case as well, as if you pass in a concrete object you get your default args back!