I have a class TestClass
and I want to share its instance between child fragment with using koin scope of parent fragment.
Is it possible to do?
Thanks.
I try:
class TestClass {
fun close() { .... }
}
class ParentFragment(): Fragment { }
val testModule = module {
scope<ParentFragment> {
scopedOf(::TestClass).onClose { it?.close() }
}
}
class Child1Fragment : Fragment {
private val testClass: TestClass by inject() // What I should write here?!
}
class Child2Fragment : Fragment {
private val testClass: TestClass by inject()
}
class Child3Fragment : Fragment {
private val testClass: TestClass by inject()
}