Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ContributesBinding assisted injection: Implicit assisted parameters is no longer supported #92

Open
plusmobileapps opened this issue Dec 6, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@plusmobileapps
Copy link

I was trying to do some assisted injection into a class which binds an interface and was getting compilation errors. Not sure if this is something even supported with anvil or if I'm doing something wrong?

interface RootBloc {
}

@Inject
@ContributesBinding(AppScope::class, boundType = RootBloc::class)
class RootBlocImpl(
    @Assisted context: ComponentContext,
) : RootBloc, ComponentContext by context {

}

Build Error:

Implicit assisted parameters is no longer supported.
Annotate the following with @Assisted: [rootBlocImpl: com.plusmobileapps.sample.anvilkmp.blocs.RootBlocImpl]
@vRallev
Copy link
Contributor

vRallev commented Dec 7, 2024

Can you share how would implement the @Provides function only with the APIs from kotlin-inject? How would you inject RootBloc?

@plusmobileapps
Copy link
Author

This is how I managed to get it to work with kotlin-inject inside my component.

@Provides
fun provideRootBloc(
    @Assisted context: ComponentContext 
): RootBloc = RootBlocImpl(context = context)

Here is the sample project with all of the source code.

@vRallev
Copy link
Contributor

vRallev commented Dec 9, 2024

Thank you. I didn't know it is supported. I don't see a reason why this cannot be supported here.

@vRallev vRallev added the enhancement New feature or request label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants