【发布时间】:2021-12-30 06:13:15
【问题描述】:
代码A来自官方样本project的末尾分支。
项目使用Hilt实现依赖注入。
我搜索了整个项目,我只找到了代码annotation class DefaultDispatcher,但我无法理解代码的含义。
Hilt 实例化的 defaultDispatche 在哪里?
代码 A
@HiltViewModel
class MainViewModel @Inject constructor(
private val destinationsRepository: DestinationsRepository,
@DefaultDispatcher private val defaultDispatcher: CoroutineDispatcher
) : ViewModel() {
...
}
@OptIn(ExperimentalMaterialApi::class)
@Composable
fun CraneHomeContent(
onExploreItemClicked: OnExploreItemClicked,
openDrawer: () -> Unit,
modifier: Modifier = Modifier,
viewModel: MainViewModel = viewModel(),
) {
...
}
@Retention(AnnotationRetention.BINARY)
@Qualifier
annotation class DefaultDispatcher
【问题讨论】:
标签: kotlin dagger-hilt