The implementation below gives and error suggesting that DataStore cannot be provided. I assumed that the UserPreferencesModule would provide this when the UserPreferencesComponent was included as a dependency for CreateAccountComponent. The fix for this for me was to omit the component and include the module directly.
@Module
class UserPreferencesModule {
@Provides
@Singleton
fun provideUserPreferencesDataStore(context: Context): DataStore<UserPreferences> = context.userPreferences
@Provides
@Singleton
fun provideUserPreferencesManager(userPreferences: DataStore<UserPreferences>): UserPreferencesManager = UserPreferencesManager(userPreferences)
}
@Component(modules = [UserPreferencesModule::class], dependencies = [CommonProvider::class])
interface UserPreferencesComponent
@Component(
modules = [
CreateAccountModule::class,
],
dependencies = [
AuthDomainComponent::class,
UserDomainComponent::class,
UserPreferencesComponent::class
CommonProvider::class
]
)
@Singleton
interface CreateAccountComponent {
val createAccountViewModel: CreateAccountViewModel
}
I am looking for an explanation why my assumption is wrong