Quick hypothetical, we’re sharing dagger/hilt acro...
# dagger
a
Quick hypothetical, we’re sharing dagger/hilt across 2 app targets in our project, one for mobile, one for wear. Is there any way we can use binds in the common module to point to a wear specific implementation and a mobile specific implementation that shares the same interface?
Copy code
@Module
@InstallIn(SingletonComponent::class)
interface AccountsModule {

    @Binds
    @Singleton
    fun bindsAccountService(accountsService: AccountsServiceImpl): AccountsService

}
Qualifiers obviously wouldn’t work here, since Binds looks for a specific implementation to return. Provides wouldn’t work, since it has no context of the actual implementation either. Is there any way around it? For context:
Copy code
:app:mobile  -- implements -->  :app:core
:app:wear    -- implements -->  :app:core
Where
:app:core
would contain the interface and
:app:target
would contain the impl. Authentication would be similar but mobile supports a full oauth flow into
AccountManager
but wear supports a device based flow, or syncing tokens from the phone into
AccountManager
,
AccountService
would be the mediator. I’m thinking of ways to re-architecture this, but wondering if this is possible