This repository was archived by the owner on Dec 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
Binds and scope annotations #43
Copy link
Copy link
Open
Description
Code lab claims this
@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?
Metadata
Metadata
Assignees
Labels
No labels