galex
04/24/2023, 10:00 AMinternal
in one module instead of two and hide all the implementation + dagger module by declaring the dagger module like this:
interface SomeInterface { .. }
internal class DefaultImpl(...): SomeInterface { ... }
@InstallIn(SingletonComponent::class)
@Module
internal abstract class SomeInterfaceDaggerModule {
@Binds
abstract fun bindsSomeInterfaceHere(impl: DefaultImpl): SomeInterface
}
And to my surprise, this works!
But does it work because the generated code is Java and the concept of internal
doesn't exist in Java, or am I missing something else here?
If so, the day dagger will generate code in Kotlin through KSP this trick will stop working, right?
🤔alex.krupa
04/24/2023, 5:21 PMimplementation
).alex.krupa
04/24/2023, 5:24 PMinternal
Dagger modules that are defined in a separate compilation modulegalex
04/25/2023, 6:23 AMalex.krupa
04/25/2023, 6:29 AMgalex
04/25/2023, 6:34 AMalex.krupa
04/25/2023, 2:46 PMgalex
04/27/2023, 9:55 AMgalex
04/27/2023, 9:59 AMinternal
instead of splitting, any thoughts?JordNullable
04/27/2023, 2:22 PMinternal
modifier, if ksp maintains that behaviour then I think this would work very well.JordNullable
04/27/2023, 2:24 PM:di
module because I think it is nice to keep your dependency injection separate from implementations. Like Alex says it is easier to swap implementations for fakes. There is always that chance (a very small one) you might change your DI library and having it separate is nice. It does mean the creation of a lot of extra Gradle projects, which is costly in larger projects but the configuration cache makes that less of a big dealJordNullable
04/27/2023, 2:25 PM