【发布时间】:2019-06-04 02:39:34
【问题描述】:
我有一个 ViewModel,它有一个依赖项,应该取自 Fragment 的 arguments。
所以它是这样的:
class SomeViewModel(someValue: SomeValue)
现在片段在其争论中收到SomeValue,如下所示:
class SomeFragment : Fragment() {
val someViewModel: SomeViewModel by viewModel()
companion object {
fun newInstance(someValue: SomeValue) = SomeFragment().apply {
arguments = bundleof("someKey" to someValue)
}
}
}
问题是我不知道如何将来自Fragment 的arguments 的SomeValue 添加到Koin 的模块中。
有没有办法让片段对 Koin 依赖图有贡献?
【问题讨论】:
标签: android kotlin dependency-injection koin