Skip to content
This repository was archived by the owner on Dec 9, 2023. It is now read-only.

Binds and scope annotations #43

@nimbalabs

Description

@nimbalabs

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions