Replies: 5 comments 6 replies
-
I believe @CircuitInject generates code that will contain an anvil annotation like "@ContributesTo" Hilt will not know how to interpret "@ContributesTo" |
Beta Was this translation helpful? Give feedback.
-
So do we need to do it manually if we use hilt? how? |
Beta Was this translation helpful? Give feedback.
-
I thought I'd add a comment on how I have tackled this with hilt. Its only basic for the time being but I've been trying Circuit out with a single @AndroidEntryPoint
class CircuitActivity : AppCompatActivity {
@Inject
lateinit var circuitConfig: CircuitConfig
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
CircuitCompositionLocals(circuitConfig) {
CircuitContent(YourRootScreen())
}
}
}
} I have one very important module I call the @Module
@InstallIn(ActivityRetainedComponent::class)
class CircuitModule {
@Provides
fun providesCircuitConfig(
uiFactories: Set<@JvmSuppressWildcards Ui.Factory>,
presenterFactories: Set<@JvmSuppressWildcards Presenter.Factory>
): CircuitConfig {
return CircuitConfig.Builder().apply {
addUiFactories(uiFactories)
addPresenterFactories(presenterFactories)
}.build()
}
} I then contributed the relevant factories as follows from relevant parts of my codebase: @Module
@InstallIn(ActivityRetainedComponent::class)
interface FeatureModule {
@Binds
@IntoSet
fun bindsScreenPresenterFactory(screenPresenterFactory: ScreenPresenterFactory): Presenter.Factory
@Binds
@IntoSet
fun bindsScreenUiFactory(screenUiFactory: ScreenUiFactory): Ui.Factory
} I've opted for the |
Beta Was this translation helpful? Give feedback.
-
We're unlikely to write first-party support for Hilt, but wouldn't be against a PR if there's something in the existing code gen we can make more reusable |
Beta Was this translation helpful? Give feedback.
-
Just wanted to close this out that Hilt is now supported thanks to @jamiesanson! |
Beta Was this translation helpful? Give feedback.
-
can we use
dagger-hilt
instead ofanvil
? From the text you wrote in the documentation, I thought the @CircuitInject only works withanvil
. right?Beta Was this translation helpful? Give feedback.
All reactions