@Binds methods must have the scoping annotations if the type is scoped, so that's why the functions above are annotated with @Singleton and @ActivityScoped. If @Binds or @Provides are used as a binding for a type, the scoping annotations in the type are not used anymore, so you can go ahead and remove them from the different implementation classes.
However, scope annotations in type are being used and works as expected in 2.40. Was it just outdated?
@ActivityScoped
class AppNavigatorImpl @Inject constructor(private val activity: FragmentActivity) : AppNavigator {
...
}
@Module
@InstallIn(ActivityComponent::class)
interface NavigationModule {
@Binds
fun providesAppNavigator(appNavigatorImpl: AppNavigatorImpl): AppNavigator
}
Same instance of AppNavigatorImpl is injected in MainActivity and ButtonFragment (child of MainActivity). Is it just outdated documentation in code labs?
Code lab claims this
However, scope annotations in type are being used and works as expected in 2.40. Was it just outdated?
Same instance of AppNavigatorImpl is injected in MainActivity and ButtonFragment (child of MainActivity). Is it just outdated documentation in code labs?