This is a Hilt extension for Voyager.
Add the following dependency to your build.gradle.kts
file:
plugins {
id("com.google.devtools.ksp") version "<KSP_VERSION>"
id("com.google.dagger.hilt.android") version "<HILT_VERSION>"
}
dependencies {
implementation("com.google.dagger:hilt-android:<HILT_VERSION>")
ksp("com.google.dagger:hilt-compiler:<HILT_VERSION>")
ksp("com.google.dagger:dagger-compiler:<HILT_VERSION>")
+ compileOnly("io.github.qdsfdhvh:voyager-hilt-ext-anootations:<VERSION>")
+ ksp("io.github.qdsfdhvh:voyager-hilt-ext-compiler:<VERSION>")
}
Just like @HiltViewModel
, but for Voyager ScreenModel.
@HiltScreenModel
class MyScreenModel @Inject constructor(
private val myRepository: MyRepository,
) : ScreenModel {
// ...
}
@HiltScreenModel(MyScreenModel.Factory::class)
class MyScreenModel @AssistedInject constructor(
@Assisted val id: Int,
private val myRepository: MyRepository,
) : ScreenModel {
// ...
@AssistedFactory
interface Factory : ScreenModelFactory {
fun create(id: Int): MyScreenModel
}
}